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

有帮助吗?

解决方案

I think the problem is that GetSel() returns the selection start and end position. You get (0,0) because no text is selected by the user.

其他提示

Solved By Tims comment. Appears the issue was tiredness and stupidity on my part!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top