在如何获取编辑框中光标的位置呀,我想在鼠标点击时获取光标的位置,以便进行字符串的插入操作?
我的做法是截取点击消息,但是m_cursorPos=GetDlgItem(IDC_EDIT_DATA)->GetCaretPos();返回值一直是1,1(k=1,y=1)...
我的做法是截取点击消息,但是m_cursorPos = GetDlgItem(IDC_EDIT_DATA)->GetCaretPos();返回值一直是1,1(k=1,y=1)?能帮我算出插入符之前有多少个字符更佳,希望能得到您的帮助?
BOOL CComputeDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if( pMsg->message == WM_LBUTTONDOWN &&
pMsg->hwnd == GetDlgItem(IDC_EDIT_DATA)->m_hWnd )
{
//m_cursorPos = GetDlgItem(IDC_EDIT_DATA)->GetCaretPos();
m_cursorPos = GetDlgItem(IDC_EDIT_DATA)->GetCaretPos();
int k= m_cursorPos.x,y= m_cursorPos.y;
}
return CDialog::PreTranslateMessage(pMsg);} 展开
BOOL CComputeDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if( pMsg->message == WM_LBUTTONDOWN &&
pMsg->hwnd == GetDlgItem(IDC_EDIT_DATA)->m_hWnd )
{
//m_cursorPos = GetDlgItem(IDC_EDIT_DATA)->GetCaretPos();
m_cursorPos = GetDlgItem(IDC_EDIT_DATA)->GetCaretPos();
int k= m_cursorPos.x,y= m_cursorPos.y;
}
return CDialog::PreTranslateMessage(pMsg);} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询