I would first call the base class method and then the desired functions:
void CEditMod::OnLButtonDown(UINT nFlags, CPoint point)
{
CEdit::OnLButtonDown(nFlags, point);
SetFocus();
int nCharIndex = CharFromPos(point);
SetSel(nCharIndex, nCharIndex);
}
//edit:
I still have no idea why the OnLButtonDown() method should be changed. Reading the text of an edit control with GetWindowText() does not seem to me to be the right way. The use of GetWindowText() is not necessary if you manage the text of the edit controls automatically via the DDX (Dialog Data Exchange). To use DDX, you need a separate CString variable in the CMyMainFrame class for each CEdit control.
class CMyMainFrame : public CFrameWnd
{
private:
CEditMod m_EditControl1, m_EditControl2, m_EditControl3;
CString m_strText1, m_strText2, m_strText3;
}
You can then use DDX functions in the CMyMainFrame class to automatically keep the variables up to date.
void CMyMainFrame::DoDataExchange(CDataExchange* pDX)
{
CFrameWnd::DoDataExchange(pDX);
DDX_Text(pDX, 1, m_strText1);
DDX_Text(pDX, 2, m_strText2);
DDX_Text(pDX, 3, m_strText3);
}
If a custom OnLButtonDown() method is used, at least the base class method must be called first.
void CEditMod::OnLButtonDown(UINT nFlags, CPoint point)
{
__super::OnLButtonDown(nFlags, point);
}