A window that receives keyboard input typically displays the characters the user types in the window's client area. A window should use a caret to indicate the position in the client area where the next character will appear. The window should create and display the caret when it receives the keyboard focus and it should hide and destroy the caret when it loses the focus. A window can perform these operations when the WM_SETFOCUS and WM_KILLFOCUS messages are processed.
Use the CreateCaret, ShowCaret, DestroyCaret and HideCaret functions to control the visibility of the caret. Use the SetCaretPosition function to change the position of the caret as the user types.