ctrl+c PreTranslateMessage

XINQITIAN 2011-04-26 11:34:36
BOOL CNewTransformDLG::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (GetDlgItem(IDC_EDIT_RECORD)->m_hWnd==pMsg->hwnd)
{
if (pMsg->message==WM_KEYDOWN)
{
if (GetKeyState('c')<0||GetKeyState('C')<0)
{
if (GetKeyState(VK_CONTROL)<0)
{
// MessageBox("complement ctrl+c"); //有检测到ctrl+c的信息,但是无法复制到数据。
return CDialog::PreTranslateMessage(pMsg);
}
}
}
if (
pMsg->message ==WM_LBUTTONDOWN||
pMsg->message ==WM_LBUTTONUP||
pMsg->message ==WM_RBUTTONDOWN||
pMsg->message ==WM_RBUTTONUP||
pMsg->message ==WM_PAINT||
pMsg->message ==WM_MOUSEMOVE||
pMsg->message ==WM_COPYDATA||
pMsg->message ==WM_COPY
)
{
return CDialog::PreTranslateMessage(pMsg);
}
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}

有检测到ctrl+c的信息,但是无法复制到数据。请告诉帮忙分析下……
...全文
162 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
XINQITIAN 2011-04-26
  • 打赏
  • 举报
回复
没有,我就只做了上面这些步骤……难倒是还需要重载什么函数嘛?
还是下面这些有消息没有写全?
if (
pMsg->message ==WM_LBUTTONDOWN||
pMsg->message ==WM_LBUTTONUP||
pMsg->message ==WM_RBUTTONDOWN||
pMsg->message ==WM_RBUTTONUP||
pMsg->message ==WM_PAINT||
pMsg->message ==WM_MOUSEMOVE||
pMsg->message ==WM_COPYDATA||
pMsg->message ==WM_COPY
)
{
return CDialog::PreTranslateMessage(pMsg);
}
fandh 2011-04-26
  • 打赏
  • 举报
回复
你是否重载复制数据了?
XINQITIAN 2011-04-26
  • 打赏
  • 举报
回复
该问题已自行解决,解决方法是,为编辑框定制一个继承于CEDIT的类完成该项功能。
XINQITIAN 2011-04-26
  • 打赏
  • 举报
回复
BOOL CMODERLESSDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class

if (
pMsg->hwnd==GetDlgItem(IDC_EDIT1)->m_hWnd
&&pMsg->message==WM_KEYDOWN
&&(pMsg->wParam =='V'||pMsg->wParam =='v')
)
{
// MessageBox("response");
return TRUE; //这里能阻止V字符输入,也支持ctrl+c的复制功能。
}
return CDialog::PreTranslateMessage(pMsg);
}
这段代码可以很成功的阻止V字符的输入,但是我要做的是阻止所有所有的字符输入,只允许复制功能,不包括黏贴,请帮忙分析我将如何实现?
BOOL CNewTransformDLG::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (GetDlgItem(IDC_EDIT_RECORD)->m_hWnd==pMsg->hwnd)
{
if (pMsg->message==WM_KEYDOWN)
{
if (GetKeyState('c')<0||GetKeyState('C')<0)
{
if (GetKeyState(VK_CONTROL)<0)
{
// MessageBox("complement ctrl+c"); //有检测到ctrl+c的信息,但是无法复制到数据。
return CDialog::PreTranslateMessage(pMsg);
}
}
}
if (
pMsg->message ==WM_LBUTTONDOWN||
pMsg->message ==WM_LBUTTONUP||
pMsg->message ==WM_RBUTTONDOWN||
pMsg->message ==WM_RBUTTONUP||
pMsg->message ==WM_PAINT||
pMsg->message ==WM_MOUSEMOVE||
pMsg->message ==WM_COPYDATA|| //是不是这里的消息声明有缺少?
pMsg->message ==WM_COPY
)
{
return CDialog::PreTranslateMessage(pMsg);
}
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}

有检测到ctrl+c的信息,但是无法复制到数据。请告诉帮忙分析下……

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧