Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.


Sets the position of the caret.

static void PASCAL SetCaretPos(
   POINT point 



Specifies the new x and y coordinates (in client coordinates) of the caret.

The SetCaretPos member function moves the caret only if it is owned by a window in the current task. SetCaretPos moves the caret whether or not the caret is hidden.

The caret is a shared resource. A window should not move the caret if it does not own the caret.

// The following code snippet shows a caret when the left 
// mouse button is pressed, and sets the caret's positon to 
// the cursor's position.

void CMyView::OnLButtonDown(UINT nFlags, CPoint point) 
   //create a solid caret, the width is 2, the length is 20.
   CreateSolidCaret (2, 20);
   SetCaretPos (point);
   ShowCaret ();

   CView::OnLButtonDown(nFlags, point);

Community Additions

© 2015 Microsoft