Moving the System Caret

The system caret is the blinking vertical bar that the user sees when editing text, but it can be placed anywhere on the screen, made any shape or size, and even made invisible. If it is invisible, it can be moved to indicate the focus location to applications without disturbing what the user sees on the screen.

Making the system caret invisible is easy: simply call the CreateCaret function to set the caret's size and shape and the SetCaretPos function to move it to wherever you are drawing the visual focus indicator (the highlighted cell, icon, button, and so on). Note that it is present but invisible, unless you explicitly make it visible.

An application should only display focus and selection indicators when they are in the active window. When the window loses activation, the application should remove the visual indicator and also call the DestroyCaret function to inform other applications. (For Win32 applications, this step is not strictly necessary, but is still good practice.)