SetCaretPos Function

Description

Moves the caret at the specified [row, column] position.

Syntax

VB/A 32bits

Private Declare Function CSSetCaretPos Lib "consoul_010205_32.dll" ( _
  ByVal hWnd As Long, _
  ByVal wRow As Integer, _
  ByVal wCol As Integer _
) As Integer

VB/A 64bits

Private Declare PtrSafe Function CSSetCaretPos Lib "consoul_010205_64.dll" ( _
  ByVal hWnd As LongPtr, _
  ByVal wRow As Integer, _
  ByVal wCol As Integer _
) As Integer

Return Value

The return value should be always 1 (one). 0 (zero) is returned if hWnd is not a valid Consoul window handle.

Parameters

hWnd

The window handle (HWND) of the Consoul window, as returned by CSCreateLogWindow.

Remarks

Consoul doesn't do any validity check on the caret position. You can create a empty console window and have the caret positioned even outside of the visible area.

Non-proportional fonts

The caret position is transformed in pixels by Consoul and aligned in columns on a multiple of CSGetCharWidth. Respectively, the row position is a multiple of CSGetLineHeight.

When using non-proportional fonts, like Times New Roman, the caret will not position itself correctly over the Nth character, where N is the column number. This is by design.

Last updated: May 13 2022.