0

I have some code which strips out illegal characters from a user entered string upon the ON_EN_CHANGE call. So need to correct the curser position if any are removed.

To do so I have been attempting to use GetSel to retrieve the position, then setsel to set it as below. f is another int variable.

m_ExportDirectory.GetWindowTextA(directory);
//characters removed here
if (rem > 0) 
{
    int j;
    m_ExportDefaultName.GetSel(f, j);
    m_ExportDirectory.SetWindowTextA(directory);
    m_ExportDefaultName.SetSel(f-rem, f-rem);
}

But getsel always sets both f & j to 0. I have attempted moving its call to above the GetWindowText but with no change.

Am I doing something stupid? If not Any ideas?

Thanks

4

2 回答 2

1

我认为问题在于GetSel()返回选择的开始和结束位置。你得到 (0,0) 因为用户没有选择任何文本。

于 2013-07-22T12:08:15.237 回答
0

由蒂姆斯评论解决。看来问题是我的疲倦和愚蠢!

于 2013-07-23T10:13:56.093 回答