CreateCaret (Compact 2013)

3/28/2014

This function creates a new shape for the system caret and assigns ownership of the caret to the specified window. The caret shape can be a line or a block.

Syntax

BOOL CreateCaret(
  HWND hWnd, 
  HBITMAP hBitmap, 
  int nWidth, 
  int nHeight
); 

Parameters

  • hWnd
    [in] Handle to the window that owns the caret.
  • hBitmap
    [in] Unsupported; set to NULL. The default caret is solid.
  • nWidth
    [in] Integer that contains the width of the caret in logical units. If this parameter is zero, the width is set to the system-defined window border width.
  • nHeight
    [in] Integer that contains the height, in logical units, of the caret. If this parameter is zero, the height is set to the system-defined window border height.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

The nWidth and nHeight parameters specify the caret's width and height, in logical units; the exact width and height, in pixels, depend on the window's mapping mode.

CreateCaret automatically destroys the previous caret shape, if any, regardless of the window that owns the caret. The caret is hidden until the application calls the ShowCaret function to make the caret visible.

The system provides one caret per queue. A window should create a caret only when it has the keyboard focus or is active. The window should destroy the caret before losing the keyboard focus or becoming inactive.

You can retrieve the width or height of the system's window border by using the ShowCaret function, specifying the SM_CXBORDER and SM_CYBORDER values. Using the window border width or height guarantees that the caret will be visible on a high-resolution screen.

Requirements

Header

winuser.h

Library

Caret.lib

See Also

Reference

Caret Functions
CreateBitmap
DestroyCaret
GetSystemMetrics
HideCaret
LoadBitmap
ShowCaret