문제

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