为什么编辑框不响应Ctrl+C和Ctrl+V呢?

zeronow 2004-04-05 08:57:08
为什么FormView中编辑框不响应Ctrl+C和Ctrl+V呢?鼠标右键的拷贝粘贴确是支持的.
...全文
127 点赞 收藏 9
写回复
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zeronow 2004-04-05
何志丹:风云伐日,十分感谢.结贴.
回复
nKeyCode需要考虑大小写吗?
我试了一下,不需要
Sorry!
回复
zeronow 2004-04-05
谢谢应该为,nKeyCode需要考虑大小写吗?

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
UINT nKeyCode = pMsg->wParam; // virtual key code of the key pressed

if (pMsg->message == WM_KEYDOWN)
{
if ( (nKeyCode == _T('C') || nKeyCode == _T('X')
|| nKeyCode == _T('V')) &&
(::GetKeyState(VK_CONTROL) & 0x8000) )
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return(TRUE);

}
}
return CFrameWnd::PreTranslateMessage(pMsg);
}
回复
BOOL CCsdn9View::PreTranslateMessage(MSG* pMsg)
{
if(WM_KEYDOWN == pMsg->message)
{
int nState = GetKeyState(VK_CONTROL);
if(nState < 0)
{
int ch = (int) pMsg->wParam ;
if('x' == ch || 'X' == ch)
::SendMessage(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(),WM_CUT,ID_EDIT_CUT,0);
if('C' == ch || 'c' == ch)
::SendMessage(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(),WM_COPY,ID_EDIT_CUT,0);
if('v' == ch || 'V' == ch)
::SendMessage(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(),WM_PASTE,ID_EDIT_CUT,0);
}
}

return CFormView::PreTranslateMessage(pMsg);
}
回复
zeronow 2004-04-05
成功结贴.

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
UINT nKeyCode = pMsg->wParam; // virtual key code of the key pressed

if ( (nKeyCode == _T('C') || nKeyCode == _T('X')
|| nKeyCode == _T('V')) &&
(::GetKeyState(VK_CONTROL) & 0x8000) )
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return(TRUE);

}
return CFrameWnd::PreTranslateMessage(pMsg);
}
回复
if(WM_KEYDOWN == pMsg->message)
{
int ch = (int) pMsg->wParam ;
if('C' == ch || 'c' == ch)
{
int nState = GetKeyState(VK_CONTROL);
if(nState < 0)
::SendMessage(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(),WM_CUT,ID_EDIT_CUT,0);
}

}
回复
zeronow 2004-04-05
利用PreTranslate,是否需要自己编程处理拷贝粘贴操作呢?谁有这方面的例子? 有无更简单的法子呀
回复
zhangcrony 2004-04-05
Should be all right!
回复
焦点不在你想要的控件上
用PreTranslate
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告
暂无公告