Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CWnd::SetCaretPos
Collapse the table of content
Expand the table of content

CWnd::SetCaretPos

Sets the position of the caret.

static void PASCAL SetCaretPos( 
   POINT 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);
}

Header: afxwin.h

Community Additions

ADD
Show:
© 2015 Microsoft