Export (0) Print
Expand All
MFC
Expand Minimize
This topic has not yet been rated - Rate this topic

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.