Skip to content

Latest commit

 

History

History
151 lines (91 loc) · 5.28 KB

nf-winuser-createcaret.md

File metadata and controls

151 lines (91 loc) · 5.28 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name req.apiset
NF:winuser.CreateCaret
CreateCaret function (winuser.h)
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, a block, or a bitmap.
CreateCaret
CreateCaret function [Menus and Other Resources]
_win32_CreateCaret
_win32_createcaret_cpp
menurc.createcaret
winui._win32_createcaret
winuser/CreateCaret
menurc\createcaret.htm
menurc
VS|winui|~\winui\windowsuserinterface\resources\carets\caretreference\caretfunctions\createcaret.htm
12/05/2018
CreateCaret, CreateCaret function [Menus and Other Resources], _win32_CreateCaret, _win32_createcaret_cpp, menurc.createcaret, winui._win32_createcaret, winuser/CreateCaret
winuser.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
User32.lib
User32.dll
Windows
19H1
CreateCaret
winuser/CreateCaret
c++
APIRef
kbSyntax
DllExport
User32.dll
Ext-MS-Win-NTUser-caret-l1-1-0.dll
api-ms-win-ntuser-ie-caret-l1-1-0.dll
ie_stubs.dll
CreateCaret
ext-ms-win-ntuser-caret-l1-1-0 (introduced in Windows 8)

CreateCaret function

-description

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, a block, or a bitmap.

-parameters

-param hWnd [in]

Type: HWND

A handle to the window that owns the caret.

-param hBitmap [in, optional]

Type: HBITMAP

A handle to the bitmap that defines the caret shape. If this parameter is NULL, the caret is solid. If this parameter is (HBITMAP) 1, the caret is gray. If this parameter is a bitmap handle, the caret is the specified bitmap. The bitmap handle must have been created by the CreateBitmap, CreateDIBitmap, or LoadBitmap function. The caret is drawn to the screen via the XOR operation.

If hBitmap is a bitmap handle, CreateCaret ignores the nWidth and nHeight parameters; the bitmap defines its own width and height. The application should not delete the hBitmap until the caret is destroyed or replaced by another caret.

-param nWidth [in]

Type: int

The width of the caret, in logical units. If this parameter is zero, the width is set to the system-defined window border width. If hBitmap is a bitmap handle, CreateCaret ignores this parameter.

-param nHeight [in]

Type: int

The height of the caret, in logical units. If this parameter is zero, the height is set to the system-defined window border height. If hBitmap is a bitmap handle, CreateCaret ignores this parameter.

-returns

Type: BOOL

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. 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.

DPI Virtualization

This API does not participate in DPI virtualization. The width and height parameters are interpreted as logical sizes in terms of the window in question. The calling thread is not taken into consideration.

-see-also

Carets

Conceptual

CreateBitmap

CreateDIBitmap

DestroyCaret

GetSystemMetrics

HideCaret

LoadBitmap

Other Resources

Reference

ShowCaret