INFO: SetCaretPos() Is Not Appropriate with CEdit or CRichEditCtrl Controls (259949)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC)

This article was previously published under Q259949

SUMMARY

You cannot use the SetCaretPos function to set the caret position for CEdit or CRichEditCtrl controls. You should use the SetSel function instead.

MORE INFORMATION

The caret is a shared resource. A window should not move the caret if it does not own the caret. You cannot use the SetCaretPos function to change the position of the caret because the control doesn't own the caret.

To move the caret, use the SetSel function and specify the same position for both the start and end parameters. This moves the text insertion point, and repositions the caret.

REFERENCES

Online help for SetCaretPos()

Modification Type:MajorLast Reviewed:7/1/2000
Keywords:kbCaret kbCursor kbinfo KB259949