Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
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 nWidthand nHeightparameters specify the caret's width and height, in logical units; the exact width and height, in pixels, depend on the window's mapping mode.
CreateCaretautomatically destroys the previous caret shape, if any, regardless of the window that owns the caret. The caret is hidden until the application calls the ShowCaretfunction 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 ShowCaretfunction, 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 |
Windows Embedded CE | Windows CE 1.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |