Useful lower-level helper functions and classes.

lclproc.pas contains lower-level classes and helper routines that are useful in LCL applications.

lclproc.pas is part of the Lazarus Component Library (LCL).

A list for method references.

TMethodList is an alias for the TMethodList type in the LazMethodList unit.

TMethodList
A node in TDebugLCLItems, holding information about a heap object. The address of the item. True when the item has been destroyed. A descriptive string for the item. Stack trace at creation of the object. Stack trace at destruction of the object. All information about the object as a string value. True to include stack traces. Destructor for the class instance. A list describing dynamically allocated (and destroyed) memory objects. The list holds descriptive information about the object, and stack traces at the time of creation and destruction. The list entries, organized as an AVL tree. Constructor for the class instance.

Sets the Name property to the value in TheName. Allocates resources for the internal TAvlTree instance used in the class.

The descriptive name of the list. Destructor for the class instance. Returns information about an item, optionally creating an entry if not found. The item information, or Nil if none was found or created. The address of the item to find. True means create an according list entry, if none existed yet. True when the item has been destroyed. True when destroyed, False when alive or not listed. The address to find. True when the item is alive. True when the item is listed and has not yet been destroyed. The address to find. Checked insert of an item. GDB exception 'RaiseDoubleCreated' when the address is already in use. The info object describing the address. The address to add. Descriptive text about the item. Checked destruction notification.
  • GDB exception 'TDebugLCLItems.MarkDestroyed' when the item was not yet created.
  • GDB exception 'RaiseDoubleDestroyed' when the item was already destroyed.
The address to mark as destroyed. Returns textual information about an object. The descriptive string. The address to find. True means include stack traces. The descriptive name of the list. Compare function for the TDebugLCLItems AVL tree. Compares the Item addresses. Compare function for Specifies a comparison function type for string values in a TStrings instance.

TStringsSortCompare is an Integer function type used to compare string values to determine the relative sort order. The return value indicates the relative sort order for the compared items, and normally contains a value like the one returned from CompareText. For example:

<0
Item1 has a value that comes before Item2.
0
Item1 and Item2 have the same value.
>0
Item1 has a value that comes after Item2.

The address for a TStringsSortCompare type is passed as an argument to the MergeSort routine.

Integer with the relative sort order for the compared values. First string value for the comparison. Second string value for the comparison. Implements a merge/sort for TStrings or TFPList.

MergeSort is an overloaded routine used to implement a comparison-based sort routine for values in List. List can be a TStrings or TFPList instance. No actions are performed in the routine when List has not been assigned (contains Nil).

The StartIndex and EndIndex arguments allow the initial and final entries in a TFPList instance to be specified. When the values are omitted, they default to the first value (position 0) and the last value (Count-1) in List.

OnCompare is the comparison routine used to determine the order for the sorted values. It can be a TListSortCompare or TStringsSortCompare function, depending on the overloaded variant of the called routine.

MergeSort implements the J. von Nuemann divide-and-conquer algorithm, with an insertion sort used for lists with 6 or fewer elements.

The list of values to sort (overloaded type). The sort compare function. The initial entry in List used in the merge/sort. The final entry in List used in the merge/sort. Converts the specified key code and shift modifier to their representation as a String. String representation for the specified value; i. e. 'Ctrl+Home'. Key code converted in the routine. Shift, Ctrl, Alt modifier converted in the routine. Indicates if the string contains the 'Word(nn)' representation for an unknown key code. True when the string is not a named virtual key code. Value examined in the method. Returns the localized textual representation for a shortcut value.

ShortCutToText is the counterpart to the TextToShortCut routine, and converts the numeric TShortCut value in ShortCut its textual representation.

ShortCut is the Word value with the modifier keys and the key code OR'd together. The high-order byte contains the Shift/Ctrl/Alt/Meta modifier(s) for the shortcut. The low-order-byte contains the virtual key code for the shortcut.

The return value contains localized versions of text for the modifiers and the key cap used in the shortcut. For example:

Ctrl+V Ctrl+Alt+Del ^V Shift+F9 Alt+G Meta+Q

Use ShortCutToTextRaw to get the text for a shortcut without localization.

TShortCut
Localized text value for the specified shortcut. TShortCut instance with the numeric shift modifier and key code handled in the routine. Converts a shortcut value to its text representation without localization.

ShortCutToTextRaw is similar to ShortCutToText, but does not use localization for the modifiers or key caps found in the shortcut.

See ShortCutToText for more information.

Use TextToShortCutRaw to create a shortcut for text which does not use localization.

Non-localized text value for the specified shortcut. Shortcut value converted in the method. Converts the textual representation for a shortcut to its TShortCut value.

TextToShortCut is a TShortcut function used to convert the string representation for a shortcut (or accelerator) to a TShortCut instance.

ShortCutText contains the text which represents a key or a key combination used as a shortcut in an application. It can contain optional key modifier(s) as well as a key caption. For example:

Ctrl+V Ctrl+Alt+Del ^V Shift+F9 Alt+G Meta+Q

Recognized key modifiers include:

Alt Ctrl or ^ Meta Shift

Recognized key captions include the standard key caps for your keyboard and the localized versions of the following:

BkSp
VK_BACK
Del
VK_DELETE
Down
VK_DOWN
End
VK_END
Enter
VK_RETURN
Esc
VK_ESCAPE
Help
VK_HELP
Home
VK_HOME
Ins
VK_INSERT
Left
VK_LEFT
PgDn
VK_NEXT
PgUp
VK_PRIOR
Right
VK_RIGHT
Space
VK_SPACE
Tab
VK_TAB
Up
VK_UP

The return value is a TShortCut instance with the numeric value used to represent both the Shift/Ctrl/Alt modifier and the key code for the shortcut. It consists of the Shift and Key values OR'd together.

Use TextToShortCutRaw to convert a non-localized string to it TShortCut equivalent.

Use ShortCutToText to reverse the process.

TShortCut
TShortcut value for the specified text. Text converted to a shortcut value in the routine. Converts the non-localized textual representation for a shortcut to a TShortCut value.

TextToShortCutRaw is similar to TextToShortCut, but does not handle or use localized versions of modifiers or key caps in ShortCutText.

See TextToShortCut for more information.

Use ShortCutToTextRaw to reverse the process.

TShortCut
TShortcut value for the specified text. Text converted to a shortcut value in the routine. Finds a string in a list, given its first few characters. The found string. The begin of the string to find. The list index where the search should start. True means case-sensitive comparison. True means search ascending from iSelStart. The list to search. Indicates if the specified key code has a value allowed in an editable text string. The virtual key code examined in the routine. Hook used to prevent circular unit references. Hook used to prevent circular unit references. Component for the change notification. Function used to send an application message using the specified parameter values. Routine used to notify the form designer which owns the specified component when it has been changed. Modified component that needs to be updated on its form design surface. Sends an application message using the specified parameter values. Executes the routine which notifies the form designer when the specified component has been changed.

The forms.pp unit provides a private implementation in its IfOwnerIsFormThenDesignerModified routine which is assigned to the variable during unit initialization.

The modified component which needs to be updated on its form design surface. Frees the TObject instance (when assigned) before setting the reference to Nil.

Calls the FreeThenNil routine in the lazutilities.pas unit from the lazutils package.

Deprecated in LCL version 3.0. Use the FreeThenNil routine in the LazUtilities.pas unit from the LazUtils package instead. LazUtilities.FreeThenNil
The object reference freed and Nil'd in the routine. . Deprecated. Indicates if the specified rectangle pointers have the same coordinate values. Deprecated in LCL version 3.99 (June 2023). Use the SameRect routine in the graphmath.pp unit (LazUtils) instead. True when the top, left, bottom, and right values in each rectangle are the same. Pointer to the first rectangle for the comparison. Pointer to the second rectangle for the comparison. Registers an initialization routine needed before the LCL is initialized. Procedure registered in the routine. Calls each of the registered initialization handlers. Registers an finalization routine needed after the LCL has been finalized. Calls each of the registered finalization handlers. Deprecated. Increments the Top, Left and Bottom, Right rectangle coordinates by the specified amounts.

Deprecated. Use the OffsetRect function in the RTL types.pp unit instead.

Deprecated in LCL version 3.0. RTL.Types.OffsetRect
Deprecated. Use GraphMath.MoveRect in the LazUtils package instead. Deprecated in LCL version 3.0. LazUtils.GraphMath.MoveRect Deprecated. Use GraphMath.MoveRectToFit in the LazUtils package instead. Deprecated in LCL version 3.0. LazUtils.GraphMath.MoveRectToFit Deprecated. Use GraphMath.MakeMinMax in the LazUtils package instead. Deprecated in LCL version 3.0. LazUtils.GraphMath.MakeMinMax Deprecated. Use GraphMath.CalculateLeftTopWidthHeight in the LazUtils package instead. Deprecated in LCL version 3.0. LazUtils.GraphMath.CalculateLeftTopWidthHeight Removes all Ampersand ('&') characters Str, and return the position for the first occurrence.

DeleteAmpersands is an Integer function used to remove all occurrences of the Ampersand character in Str. The return value contains the position in Str where the first occurrence of the of the character was found.

Double Ampersands (&&) are converted to a single & character in Str.

DeleteAmpersands can be used to remove the prefix used for accelerator keys in button, tool bar, and menu captions.

Position where the first ampersand character was found. String with values converted in the method. Removes single Ampersand characters, and returns the converted value.

RemoveAmpersands is an overloaded function used to remove all occurrences of a single Ampersand (&) character from the specified value. It provides variants that operate on String and PChar types. The return value contains the original value after all single Ampersand characters have been removed. Double Ampersand (&&) characters are converted into a single Ampersand character.

Use DeleteAmpersands to remove Ampersand character in the original String value.

Value after single Ampersand characters are removed. String with the values examined in the routine. PChar value examined in the routine. Length of the value in Src. Compares two Handles, returning the relative order for the handle values.

The return value contains the following:

-1
h1 has a lower value than h2.
0
h1 and h2 have the same value.
1
h1 has a higher value than h2.
Relative order for the compared handle values. First handle for the comparison. Second handle for the comparison. Compares the specified TPoint values to get their relative order.

ComparePoints is an Integer function used to compare the coordinates in the specified TPoint instances to determine their relative order. The return value contains -1, 0, or 1 for the following conditions:

-1
p1.y is smaller than p2.y, or p1.x is smaller than p2.x.
0
p1 and p2 have the same x and y values.
1
p1.y is larger than p2.y, or p1.x is larger than p2.x.
Relative order for the compared TPoint values. First TPoint instance for the comparison. Second TPoint instance for the comparison. See ComparePoints.

See ComparePoints.

Raises a catchable exception.

Normally, GDB does not catch FPC Exception objects. This procedure raises a standard divide by zero exception which is caught by GDB.

Writes a number of strings (heavily overloaded) to the debug output. A single string, or a Format string when followed by an argument list. Writes the formatted dump of the typed arguments. Optionally writes a value to the debugger and increases the indentation level. Optionally writes a value to the debugger and decreases the indentation level. Signals the OnDbgOut event handler for the debug logger class instance. Formats debug output for various argument types (overloaded).
  • boolean: "True" or "False".
  • pointer: hexadecimal address.
  • TRect, TPoint: shows the x/y coordinates.
  • TComponentState: set.
  • TObject: Name:ClassName.
  • TClass: ClassName.
  • String, WideString: chars > #126 are translated into #nn (or #nnnn) character constants.
Returns the component or class name. Converts control characters, or characters above #126 into #hex format. Converts control characters, or characters above #126 into #hex format. Provides an hex dump of a memory section. The formatted dump. The start address. The number of bytes to dump. The number of bytes per line, zero for no line breaks. Provides a hex dump of an memory stream.

The dump starts at the current stream position, the position moves to the end of the dumped range.

The maximum number of bytes to dump. Provides an hex dump of an TObject. Provides a hex dump of an Int64 value, (sign + absolute value). Provides a dump of SetWindowPosition flags. Converts a virtual key code to its String representation. Writes a debugging message to the log file for the current thread. Writes a debugging message to the log file for the current thread which includes the thread identifier. Writes data to a file. Appends a line to the given file. Appends (pre-formatted) text to an file. Calls the Finish method for the debug logger class instance. Indicates if a TClass instance is found in the specified array. Ordinal position in ACase where the TClass instance was found, or -1 when not found. TClass instance to locate in ACase. Array of TClass instances to examine in the routine. True to consider descendants of AClass as a match in the routine. Deprecated. Use the LazUTF16.UTF16CharacterLength routine instead. Deprecated in LCL version 4.0 (July 2023). Deprecated. Use the LazUTF16.UTF16Length routine instead. Deprecated in LCL version 4.0 (July 2023). Deprecated. Use the LazUTF16.UTF16CharacterToUnicode routine instead. Deprecated in LCL version 4.0 (July 2023). Deprecated. Use the LazUTF16.UnicodeToUTF16 routine instead. Deprecated in LCL version 4.0 (July 2023). Replaces last digits with 1.

For example Name321 becomes Name1.

Deprecated, see the LazUTF8 unit in the LazUtils package for replacements. Indicates if the specified name contains 'default'. True when AName contains 'default'. Font name examined in the routine.