下面的代码可以屏蔽掉密码框的“Ctrl+V”。BOOL CLoginDlg::PreTranslateMessage(MSG* pMsg)
{
if(GetFocus()==GetDlgItem(IDC_txtPASSWORD))
{
if(pMsg->wParam =='V' && GetKeyState(VK_CONTROL)<0)
{
//Clear();
}
}
return CDialog::PreTranslateMessage(pMsg);
}
又有两个问题要请教:
1、如何让密码框弹出的右键菜单中的那个“粘贴”选项失效?
2、如何截获“WM_PASTE”消息?下面的写法好像不行。BOOL CLoginDlg::PreTranslateMessage(MSG* pMsg)
{
if(GetFocus()==GetDlgItem(IDC_txtPASSWORD))
{
if(pMsg->wParam==WM_PASTE)
{
AfxMessageBox("pastess");
}
}
return CDialog::PreTranslateMessage(pMsg);
}
{
if(GetFocus()==GetDlgItem(IDC_txtPASSWORD))
{
if(pMsg->wParam =='V' && GetKeyState(VK_CONTROL)<0)
{
//Clear();
}
}
return CDialog::PreTranslateMessage(pMsg);
}
又有两个问题要请教:
1、如何让密码框弹出的右键菜单中的那个“粘贴”选项失效?
2、如何截获“WM_PASTE”消息?下面的写法好像不行。BOOL CLoginDlg::PreTranslateMessage(MSG* pMsg)
{
if(GetFocus()==GetDlgItem(IDC_txtPASSWORD))
{
if(pMsg->wParam==WM_PASTE)
{
AfxMessageBox("pastess");
}
}
return CDialog::PreTranslateMessage(pMsg);
}
解决方案 »
- 【求助】 不同对话框的控件ID可以相同吗?
- vs2010下MDI多文档多视图基于formview怎么个切换视图比较好呢?
- Edit控件如何显示动态显示最右侧数据
- 微机原理和计算机原理方面的书籍
- 问一个概念, CRect m_r = new CRect(1,2,3,4); delete &m_r; 这样错在哪里?
- 瀹㈡埛鍖虹殑閲嶇粯闂
- ★★★关于PE文件的问题,读BCB或Delphi编译的EXE中的引入表时出错,VC的就可以,这是怎么回事?★★★
- 关于send(s, strSubAddr,strlen(strSubAddr),0)函数?送分喽!!
- win2000server中装vc,vb与其它系统有所不同吗?
- 我送分!!!!!
- 求多边形形心坐标算法
- 困惑
The implementation is below:
/*Overridet this message to disable the menu*/
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
/*
Since the Classwizard couldn't help us add handler for WM_PASTE.
We add it by hand.
*/
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
//{{AFX_MSG_MAP(CMyEdit)
ON_WM_RBUTTONDOWN()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_PASTE,OnPaste)
END_MESSAGE_MAP()
/*
Override this message to disable paste from clipboard.
*/
afx_msg LRESULT OnPaste(WPARAM p,LPARAM l);/*
Overridet this message to disable the menu
*/
void CMyEdit::OnRButtonDown(UINT nFlags, CPoint point)
{
// CEdit::OnRButtonDown(nFlags, point);
return;
}
/*
Override this message to disable paste from clipboard.
*/LRESULT CMyEdit::OnPaste(WPARAM p,LPARAM l)
{
return FALSE;
}---------------------------------->
Ok.The work is done.Don't forget the check the "Password" property in the Edit's
property dialog.
Make a revision:
Move the line:
"afx_msg LRESULT OnPaste(WPARAM p,LPARAM l);"
To the line below:
"afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
"