c++mfccedit

GetSel always returning 0,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


Solution

  • 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.