Dela via


CWnd::SetCaretPos

Sets the position of the caret.

static void PASCAL SetCaretPos( 
   POINT point  
);

Parameters

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

Remarks

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.

Example

// 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);
}

Requirements

Header: afxwin.h

See Also

Concepts

CWnd Members

Reference

CWnd Class

Hierarchy Chart

CWnd::GetCaretPos

SetCaretPos