CEdit(Ctrl + X,C,V,Z,A)(剪贴板功能) [英] CEdit (Ctrl + X, C, V, Z, A) (Clipboard functions)
本文介绍了CEdit(Ctrl + X,C,V,Z,A)(剪贴板功能)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从CEdit
类进行子类化时,默认剪贴板功能(Ctrl + X,C,V,Z,A)(使用键盘输入& 不是上下文菜单)不会起作用.
如何在基于CDialog
的应用和所以对于SDI或MDI应用程序上的CFormView
!
请帮助我
When subclassing from a CEdit
class, the default clipboard functions (Ctrl + X, C, V, Z, A) (Using the keyboard input & not the context menu) wont work.
How to make it possible in both CDialog
based apps & so for CFormView
on SDI or MDI apps !?
Help me please
推荐答案
BOOL CEditEx::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
// Intercept Ctrl + Z (Undo), Ctrl + X (Cut), Ctrl + C (Copy), Ctrl + V (Paste) and Ctrl + A (Select All)
// before CEdit base class gets a hold of them.
if (pMsg->message == WM_KEYDOWN && ::GetKeyState(VK_CONTROL) < 0)
switch (pMsg->wParam)
{
case 'Z':
Undo();
return TRUE;
case 'X':
Cut();
return TRUE;
case 'C':
Copy();
return TRUE;
case 'V':
Paste();
return TRUE;
case 'A':
SetSel(0, -1);
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
您需要在应用程序中添加键盘处理,并根据需要响应这些键组合.当您收到CTL + C
时,应致电CEdit::Copy()
[ ^ ]函数,等等.
You need to add keyboard handling in your application and respond to these key combinations as required. When you receive aCTL + C
you should call theC:Copy()
[^] function, etc.
这篇关于CEdit(Ctrl + X,C,V,Z,A)(剪贴板功能)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文