unit KOL.pas


Please note, that KOL does not use keyword 'class'. Instead, poor Pascal 'object' is the base of our objects. So, remember, how we worked earlier with such Object Pascal's objects:
- to create objects dynamically, use P<objname> instead of T<objname> to allocate a pointer for dynamically created object instance;
- remember, that constructors of objects can not be virtual. Override procedure Init instead in your own derived objects;
- rather then call constructors of objects, call global procedures New<objname> (e.g. NewLabel). If not, first (for virtualally created objects) call New( ); then call constructor Create (which calls Init) - but this is possible only if the constructor is overriden by a new one.
- the operator 'is' is not applicable to objects. And operator 'as' is not necessary (and is not applicable too), use typecast to desired object type, e.g.: "PSomeObjectType( C )" inplace of "C as TSomeClassType".


Also remember, that IF [ MyObj: PMyObj ] THEN NOT[ with MyObj do ] BUT[ with MyObj^ do ] Though it is possible to skip '^' symbol when accessing member fields, methods, properties, e.g. [ MyObj.Execute; ]
objects functions by category
_TObj TObj
TList TListEx TStrList TStrListEx
TTree TDirList TIniFile TCabFile TStream
TControl
TGraphicTool TCanvas TImageList TIcon TBitmap TGif TGifDecoder TJpeg
TTimer TThread TTrayIcon TDirChange TMediaPlayer
TMenu TOpenSaveDialog TOpenDirDialog TColorDialog
TAction TActionList
Exception
Visual objects constructing functions

   Working with null-terminated and ansi strings
   Small bit arrays (max 32 bits in array)
   Arithmetics, geometry and other utility functions
   Data sorting (quicksort implementation)
   String to number and number to string conversions
   64-bit integer numbers
   Floating point numbers
   Date and time handling
   File and directory routines
   System functions and working with windows
   Text in clipboard operations
   Wrappers to registry API functions
Following conditional symbols can be used in a project (Project ¦ Options ¦ Directories/Conditional Defines) to change code generated a bit. There are following:
EXTERNAL_KOLDEFS      - since there are a lot of such symbols, it may be not
possible to include all the desired optional symbols
in the Project Options (Delphi has a restriction to 256
characters in a semicolon-separated list of included
options). This symbol allows to exceed this restriction:
you place your defines in an included file
EXTERNAL_DEFINES.INC, located in your project directory.
Since this is a normal pascal source, use usual Pascal
syntax:  add a directive (*$DEFINE symbol*) for each
symbol you want, and you can decorate it with usual
comments if necessary.
ENABLE_DEPRECATED     - some old declaration made "deprecated" and moved to
KOL_deprecated.inc. This symbol provides including
such declarations into KOL.pas and makes it available
again.
DISABLE_DEPRECATED    - (default) - disables deprecated declaration.
WIN                   - (default) - version for Windows.
LINUX                 - version for Linux (only PAS_VERSION) -- not yet ready
When not defined, symbol WIN is defined automatically.
LINUX_USE_HOME_STARTFDIR - in Linux app, HOME directory of the user will be
returned by GetStartDir function.
GTK                   - version for GTK (Linux or Win32) -- not yet ready
XQT                   - version for QT (Linux or Win32) -- not yet ready
FPC                   - Free Pascal version. KOL can be used with such compiler
to create Win32 applications. To create Win-CE
applications (with FPC compiler)), use the separate
version of KOL specially designed for it.
INPACKAGE             - version for Mirror Classes Library package (design-time
only). This option should be included only in MCK package
options and never in options of the KOL/MCK application.
PAS_VERSION           - to use Pascal version of the code.
PARANOIA              - to force short versions of asm instructions (for D5
and below, D6 and higher use those instructions always).
USE_CMOV              - force using CMOV machine instruction in asm code (not
recommended, still on some machines your application
will not work).
SMALLEST_CODE         - to create minimal code application (affected:
(o) SimpleGetCtlBrushHandle - returns solid silver brush
always;
(o) _NewWindowed
- only default system font used by default;
font of the parent control is not applied to its
children automatically (but see SMALLEST_CODE_PARENTFONT);
- fBrush always set to NIL by default (parent Brush
is not applied);
(o) WndProcDoEraseBkgnd
- child controls windows are not created in WM_ERASEBKGND
if were not created earlier (in most case, all OK
with this - controls are created BTW);
- SetBkColor, SetBkMode, SetBrushOrgEx are not
called (all OK therefore)
(o) by default, NOT_UNLOAD_RICHEDITLIB is defined if
UNLOAD_RICHEDITLIB is not defined in project options
(this minimizes finalization section).
(o) _NewControl
- BoundsRect initialized with a rectangle
(aParent.fMarginLeft, aParent.fMarginTop,
aParent.fMarginLeft+64, aParent.fMargin+64)
rather then with (aParent.fMargin+aParent.fMarginLeft,
aParent.fMargin+aParent.fMarginTop,
aParent.fMargin+aParent.fMarginLeft+64,
aParent.fMargin+aParent.fMarginTop+64).
In most cases this is enough.
(o) Int2Hex
there are no check for second perameter > 15
(o) .... other see in code
SMALLER_CODE          - like smallest code, but fuctionality is the same.
The speed can be lower therefore.
SMALLEST_CODE_PARENTFONT - Parent font therefore is applied for child controls,
but initially only.
NOT_USE_KOLMATH       - Only for _X_ (GTK + Linux): to prevent referencing
KOLmath in uses. This makes method TCanvas.Arc
unavailable, but the application become smaller.
NOT_USE_EXCEPTIONS    - to prevent referencing unit ERR.PAS in uses even when
KOLmath is listed there.
REDEFINE_ABS          - usual Abs works as a macro which is better in most
cases. But who knows...
CUSTOM_APPICON        - when this option is defined, the resource name for the
application icon is extracted from a file
CusomAppIconRsrcName_PAS.inc (place it in your project
folder and type there name of the recource in qutations).
By default, string 'MAIN' is used like in usual Delphi
application.
USE_NAMES             - to use property Name with any TObj. This makes also
available method TObj.FindObj( name ): PObj.
UNIQUE_NAMES          - provide Name property to be unique among all siblings.
USE_MHTOOLTIP         - to use KOLMHTOOLTIP.pas (actually it is not a separate
unit but a set of portions of code included into KOL.pas
in different places). This unit provides tooltips (hints)
for arbitrary controls which appear when mouse is over
such controls.
USE_GRUSH             - to use ToGRush.pas unit, which provides automatic
redirection of the most cintrols creation functions
to the KOLGRushControls.pas.
(USE_CONSTRUCTORS     - to use constructors like in VCL. Note: this option is
not carefully tested!)
TLIST_FAST            - very fast implementation of TList (for coast of some
additional code).
DFLT_TLIST_NOUSE_BLOCKS - for TLIST_FAST: by default, do not make all TList
objects using new (fast) algoritms, but only those of
TList objects, which property UseBlocks was set to
TRUE after creating it.
STREAM_LARGE64        - turns on support of streams (and files) of size larger
then 4 Gbytes. Data type Int64 used for parameters of
the most of methods and functions in such case. (Note:
Int64 was introduced since Delphi5, so in earlier Delphi
versions using this symbol is not possible).
STREAM_COMPAT         - still STREAM_LARGE64 appeared (in v2.84), most of
methods and functions declarations became incompatible
with earlier created extensions. This symbol provides
compatibility for such extensions, but it desables
using large streams.
OLD_STREAM_CAPACITY   - to use elder TStream.SetCapacity algorithm (it did not
make Capacity smaller than already achieved, but in
newer version, Capacity can be set to a smaller value,
and for memory streams, rest of memory is freeing in
such case).
OLD_MEMSTREAMS_SETSIZE - to use elder TStream.SetSize for memory streams. In
a new version, setting new size also changes Capacity
to the same value (in earlier case, a value for
Capacity property was calculated to become a bit
greater then a value set for Size property).
OLD_COMPAT            - to use symbol ';' as a file list separator (all operations
using DoFileOp function such as DeleteFile2Recycle and
CopyMoveFiles).
OLD_REGKEYGETSUBKEYS  - to use elder version of RegKeyGetSubKeys functions
(new version is faster).
OLD_REGKEYGETVALUENAMES - to use elder version of RegKeyGetValueNames
(newer version is faster).
USE_CUSTOMEXTENSIONS  - to extend TControl with custom additions.
UNICODE_CTRLS         - to use Unicode versions of controls (WM_XXXXW messages,
etc.)
SAFE_CODE             - use more safe code in some algorithms (but more slowly
and taking more code a bit).
USE_OnIdle            - to use OnIdle event
SNAPMOUSE2DFLTBTN     - for all MessageBox-based functions, snap mouse to
default button is provided if such option is on in
mouse driver settings.
BUTTON_DBLCLICK       - to prevent clicking buttons with double click (separate
event OnMouseDblClk is fired in such case), this takes
smaller code but buttons can not be pressed with mouse
fast. When SMALLEST_CODE on, this option also is on.
ALL_BUTTONS_RESPOND_TO_ENTER - obvious (by default, buttons respond to key
SPACE, since those are working this way in Windows).
CLICK_DEFAULT_CANCEL_BTN_DIRECTLY - to prevent visual effect of default/cancel
button pressing with Enter/Escape keys. Also, button
don't become focused in such case.
DEFAULT_CANCEL_BTN_EXCLUSIVE - to disable assigning to a button properties
DefaultBtn and CancelBtn simultaneously.
NO_DEFAULT_BUTTON_BOLD - to prevent DefaultBtn to be visually with
a bold border.
BITBTN_DISABLEDGLYPH2 - to restore old behaviour of multi-glyph bitbtn, when
index 2 was used to represent the button in disabled
state, and glyph with index 1 was used forpressed dtate.
Now by default index 1 corresponds to the disabled state,
and index 2 to the pressed state, i.e. these are swapped.
ESC_CLOSE_DIALOGS     - to allow closing all dialogs with ESCAPE.
KEY_PREVIEW           - form also receive WM_KEYDOWN (OnKeyDown event fired)
SUPPORT_ONDEADCHAR    - to support OnKeyDeadChar event in responce to
WM_DEADCHAR, WM_SYSDEADCHAR
OpenSaveDialog_Extended - to allow using custom extensions for OpenSaveDialog.
AUTO_CONTEXT_HELP     - to use automatic respond to WM_CONTEXTMENU to call
context help.
NOT_FIX_CURINDEX      - to use old version of TControl.SetItems, which could
lead to loose CurIndex value (e.g. for Combobox)
NOT_FIX_MODAL         - not to fix modal (if fixed, click on any window
activates the application. If not fixed, code is
smaller very a little, but only click on modal form
activates the application). This does not fix calling
MsgBox though.
MODAL_ACTIVATE_FIX    - if this option is set, all the windows of clicked app
with active modal form are brought to foreground, not
only modal form itself. This option is not necessary if
only two forms are visible at a time (the main form and
the active modal form).
NEW_MODAL             - to use extended modalness.
USE_SETMODALRESULT    - to guarantee ModalResult property assigning handling.
USE_SHOWMODALPARENTED_ALWAYS - to use TControl.ShowModalParented( Applet )
instead of TControl.ShowModal always.
USE_MENU_CURCTL       - to use CurCtl property in popup menu to detect which
control initiated a pop-up.
NEW_MENU_ACCELL       - to use new menu accelerators handling, without
AcceleratorTable (not tested for all cases)
USE_DROPDOWNCOUNT     - to force setting combobox dropdown count.
NOT_UNLOAD_RICHEDITLIB - to stop unload Rich Edit library in finalization
section (to economy several byte of code).
NOT_USE_RICHEDIT      - not use richedit (it will not be possible to create richedit)
TV_DRAG_RBUTTON       - to allow dragging tree view items with right mouse
button too.
TOOLBAR_FORCE_CHILDALIGN - this option provides Align working for child
controls of the toolbar control, but when with this option
is turned on it is impossible to have neighbour controls
on a form correctly aligned. This last disadvantage is
not important if a toolbar is always placed on a separate
panel-like control as a child.
Note: this option has no effect for Win9x, still use of
it under Win9x can crash the application!!!
TOOLBAR_DOT_NOAUTOSIZE_BUTTON - this option forces prefix dot character in
button caption to be treated as an instruction to
remove TBSTYLE_AUTOSIZE from the button style. Actually,
this feature not necessary still custom button size can
be set even if such style is on for a button.
CANRESIZE_THICKFRAME  - to use elder version of CanResize, changing border
style of the window (this cause incorrect form view in
Vista Aero theme (due a bug in Vista?)).
ANCHORS_WM_SIZE       - to check WM_SIZE message in Anchor handling window
procedure. By default, now used WM_WINDOWPOSCHANGED.
USE_PROP              - to use GetProp / SetProp (old style) in place of
Get / SetWindowLong( wnd, GWL_USERDATA... ) (slower?)
PROVIDE_EXITCODE      - PostQuitMessage( value ) assigns value to ExitCode
INITIALFORMSIZE_FIXMENU - form size initially is really the same as defined at
design time even for forms having main menu bar
USE_GRAPHCTLS         - to use graphic (non-windowed) controls
RICHEDIT_XPBORDER     - provide correct drawing rich edit control border with
XP themes.
GRAPHCTL_XPSTYLES     - to use XP themed Visual styles for drawing graphic
controls. This does not affect windowed controls
which visual style is controlled by the manifest.
This option also turns on RICHEDIT_XPBORDER option.
GRAPHCTL_HOTTRACK     - to use hot-tracking also together with XP themed
graphic controls (otherwise only static XP themed
view is provided). Also, turn this option on if you
want to handle OnMouseEnter and OnMouseLeabe events
for graphic controls.
NEW_OPEN_DIR_STYLE_EX - to use new code for TOpenDirDialog, which provides
correct working of the dialog with an option
odNewDialogStyle set (even in Windows 9x system).
HTMLHELP_NOTOP        - when Html help is called, its window become a child of
the desktop, not application (in such case it is not
closed together with the application, and it is apper
not on top of the application).
ICON_DIFF_WH          - to support icons having Width <> Height
ICONLOAD_PRESERVEBMPS - when an icon is loaded, its bitmap and mask are
extracted and in case when such symbol is defined,
these one or two bitmaps are preserved until TIcon
object is destroyed.
LOADEX                - to use TBitmap.LoadFromStreamEx while loading icon
from a stream or a file.
USE_OLDCONVERT2MASK   - to use elder Convert2Mask method (newer is more correct).
FIX_TRANSPBMPPALETTE  - for TBitmap.StretchDrawMasked, bitmaps with PixelFormat
= pf4bit or pf8bit are first converted (in a temporary
TBitmap object) to pf32bit, and then are drawn. This
fixes problems with palette usage for such DIB bitmaps.
FILL_BROKEN_BITMAP    - TBitmap.LoadFromStreamEx: broken bitmaps rest of
scanlines are be filled with zeroes (usually black color)
rather then left containing trash memory bits.
AUTO_REPLACE_CLEARTYPE- to replace automatically CLEARTYPE_QUALITY fonts
with ANTIALIASED_QUALITY when running under elder
Windows version than XP.
FORCE_ALTERNATEFILENAME- TDirList.ScanDirectoryFORCE_ALTERNATEFILENAME - forced
using an alternate file path and filename for unicode
paths (принудительное использование альтернативного имени
пути и имени файла для юникод путей)
NEW_GRADIENT - to use new gradient painting by homm (fast).
OLD_ALIGN    - to prevent using new Align by Galkov.
NEW_ALIGN    - (default) - to use new Align implementation (faster).
OLD_TRANSPARENT       - to prevent using NEW_TRANSPARENT
NEW_TRANSPARENT       - created by Alexander Karpinsky a.k.a. homm (faster)
SBOX_OLDPOS           - to use elder formulas to calculate scroll box positions
(just for compatibility with very old apps using it).
OLD_REFCOUNT          - to prevent using new RefInc / RefDec behaviour
(new style of using RefCount works better).
OLD_FREE              - to declare Free as a method as in earlier versions of KOL.
In new versions, Free is declared as a property, and
"calling" it just redirects call to RefDec. OLD_FREE
can be used for compatibility with compilers not
understanding "calling" a property without assigning
something to or from it (Turbo Delphi?).
SCROLL_OLD            - for compatibility with the old applications using
TScrollBar: there was another method of adjusting
SBMax and SBPageSize: SBMax should be corrected to
(nMaxItems-1-SBPageSize).
FILE_EXISTS_EX - to use more correct (but a bit large code in FileExists functon)
USE_AUTOFREE4CONTROLS - (default) - from 2.40, most of control sub-objects are
destroying using Add2AutoFree (smaller code).
NOT_USE_AUTOFREE4CONTROLS - this option returns to previous behaviour (just to
compare code size). Will be deprecated in future.
ENDSESSION_HALT - to halt the process when WM_ENDSESSION comes.
FILESTREAM_POSITION   - in PAS_VERSION, Stream..fData.fPosition always show
current position (for debug purposes)
PSEUDO_THREADS        - to use pseudo-threads instead of normal threads.
WAIT_SLEEP            - for PSEUDO_THREADS: sleep 10 ms in a
WaitForMultipleObjects loop.
ENUM_DYN_HANDLERS_AFTER_RUN - to allow all the events handling even when
AppletTerminated become TRUE.
STOP_WNDPROCTRANSPARENT_AFTER_APPLETTERMINATED - use this long-named otpion to
prevent any functionality of WndProcTransparent after
AppletTerminated is set to true.
STOPTIMER_AFTER_APPLETTERMINATED - use this symbol to prevent timer event
firing after setting AppletTerminated to TRUE.
TIMER_APPLETWND       - to use Applet window to handle WM_TIMER events
(otherwise special single invisible window is created
to handle such events).
SUPPORT_LONG_TIMER    - LINUX only: set this option if TTimer.Interval can be
set to a value greater then 1,800,000 (30 minutes).
DEBUG_MENU            - to debug menu.
DEBUG_GDIOBJECTS      - to allow counting all the GDI objects used.
CHK_BITBLT            - to check BitBlt operations.
DEBUG_ENDSESSION      - to allow debugging WM_ENDSESSION handling.
DEBUG_CREATEWINDOW    - to debug CreateWindow.
CRASH_DEBUG           - to fill object memory with $DD before freeing it
(program really crashes when the object is
attempted to destroy more then once and in most
cases when a destroyed object is accessed after the
destruction).
DEBUG_MCK             - specially designed to debug Mirror Classes Kit.
DEBUG                 - other debugging.
EXTERNAL_DEFINES      - if count of options necessary to set is very large
Delphi ignores past of those. To avoid this problem,
set only this option in Project's options, and place
all other options to ExternalDefines.inc file as a
sequence of {$DEFINE ... directives.
But note, such file should be located in a
project directory, but not in the directory where KOL.pas
is located. This is enough to provide different sets
of defines for each project.

Content

type PObj = ^ TObj;

type PList = ^ TList;

type TObjectMethod = procedure of object;

type TOnEvent = procedure( Sender: PObj ) of object;
This type of event is the most common - event handler when called can know only what object was a sender of this call. Replaces good known VCL TNotifyEvent event type.

function NewList: PList;
Returns pointer to newly created TList object. Use it instead usual TList.Create as it is done in VCL or XCL.

function NewListInit( const AItems: array of Pointer ): PList;
Creates a list filling it initially with certain Items.

procedure FastIncNum2Elements( List: TList; FromIdx, Count, Value: Integer );
Very fast adds Value to List elements from List[FromIdx] to List[FromIdx+Count-1]. Given elements must exist. Count must be > 0.

procedure Free_And_Nil( var Obj );
Obj.Free and Obj := nil, where Obj *MUST* be TObj or its descendant (TControl, TMenu, etc.) This procedure is not compatible with VCL's FreeAndNil, which works with TObject, since this it has another name.

type TOnThreadExecute = function( Sender: PThread ): Integer of object;
Event to be called when Execute method is called for TThread

function NewThread: PThread;
Creates thread object (always suspended). After creating, set event OnExecute and perform Resume operation.

function NewThreadEx( const Proc: TOnThreadExecute ): PThread; stdcall;
Creates thread object, assigns Proc to its OnExecute event and runs it.

function NewThreadAutoFree( const Proc: TOnThreadExecute ): PThread;
Creates thread object similar to NewThreadEx, but freeing automatically when executing of such thread finished. Be sure that a thread is resumed at least to provide its object keeper freeing.

function _NewStream( const StreamMethods: TStreamMethods ): PStream;
Use this method only to define your own stream type. See also declared below (in KOL.pas) methods used to implement standard KOL streams. You can use it in your code to create streams, which are partially based on standard methods.

function NewFileStream( const FileName: KOLString; Options: DWORD ): PStream;
Creates file stream for read and write. Exact set of open attributes should be passed through Options parameter (see FileCreate where those flags are listed).

function NewFileStreamWithEvent( const FileName: KOLString; Options: DWORD ): PStream;
Creates file stream for read and write. Exact set of open attributes should be passed through Options parameter (see FileCreate where those flags are listed). Also, resulting stream is supporting OnChangePos event.

function NewReadFileStream( const FileName: KOLString ): PStream;
Creates file stream for read only.

function NewReadFileStreamWithEvent( const FileName: KOLString ): PStream;
Creates file stream for read only, supporting OnChangePos event.

function NewWriteFileStream( const FileName: KOLString ): PStream;
Creates file stream for write only. Truncating of file (if needed) is provided automatically.

function NewWriteFileStreamWithEvent( const FileName: KOLString ): PStream;
Creates file stream for write only. Truncating of file (if needed) is provided automatically. Created stream supports OnChangePos event.

function NewReadWriteFileStream( const FileName: KOLString ): PStream;
Creates stream for read and write file. To truncate file, if it is necessary, change Size property.

function NewReadFileStreamW( const FileName: WideString ): PStream;
Creates file stream for read only.

function NewWriteFileStreamW( const FileName: WideString ): PStream;
Creates file stream for write only. Truncating of file (if needed) is provided automatically.

function NewReadWriteFileStreamW( const FileName: WideString ): PStream;
Creates stream for read and write file. To truncate file, if it is necessary, change Size property.

function NewExFileStream( F: HFile ): PStream;
Creates read only stream to read from opened file or pipe from the current position. When stream is destroyed, file handle still not closed (your code should do this) and file position is not changed (after the last read operation).

function NewMemoryStream: PStream;
Creates memory stream (read and write).

function NewMemoryStreamWithEvent: PStream;
Creates memory stream (read and write). Created stream support OnChangePos event.

function NewExMemoryStream( ExistingMem: Pointer; Size: DWORD ): PStream;
Creates memory stream on base of existing memory. It is not possible to write out of top bound given by Size (i.e. memory can not be resized, or reallocated. When stream object is destroyed this memory is not freed.

function NewConcatStream( Stream1, Stream2: PStream ): PStream;
Creates a stream which is a concatenation of two source stream. After the call, both source streams are belonging to the resulting stream and these will be destroyed together with the resulting stream. (So forget about it). After the call, first stream will not be changed in size via methods of concatenated stream (and it is not recommended to use further Stream1 and Stream2 methods too). But Stream2 can still be increased, if it allows doing so when some data are appended or Size of resulting stream is changed (but not less then Stream1.Size). Nature and physical location of Stream1 and Stream2 are not important and can be absolutely different. But it is supposed that both streams are not compressed and its Size is known always and Seek operation is valid. This function accepts recursive (multi-level) usage: resulting concatenation stream can be used as a left or right parameter to create another concatenation stream later, so it is possible to build a tree of streams concatenated, concatenating this way several different streams and use it as a single data streaming object.

function NewSubStream( BaseStream: PStream; const FromPos, Size: TStrmSize ): PStream;
Creates a stream which is a subpart of BaseStream passes, starting from FromPos and with given Size. Like in function NewConcatStream, passes BaseStream become owned by newly created sub-stream object, and will be destroyed automatically together with a sub-stream. If you want to provide more long life time for a base stream (e.g. if you plan to use it after a sub-stream based on it is destroyed), use method RefInc for base stream once to prevent it from destroying when the sub-stream is destroyed. Note: be careful and avoid direct calling methods and properties of the base stream, while you have a sub-stream created on base it, since the sub-stream actually redirects all the requests to the parent base stream. Sub-stream accepts setting Size to greater value later, and if some data are written to it, it is written actually to the base stream, and when it is written beyond the end position, this will increase size of the base stream too (and if it is a file stream, this also will increase size of the file on which the base stream was created). This function accepts recursive (multi-level) usage: it is possible to create later another sub-stream on base of existing sub-stream, still it is actully can be treated as usual stream.

function Stream2Stream( Dst, Src: PStream; const Count: TStrmSize ): TStrmSize;
Copies Count (or less, if the rest of Src is not sufficiently long) bytes from Src to Dst, but with optimizing in cases, when Src or/and Dst are memory streams (intermediate buffer is not allocated).

function Stream2StreamEx( Dst, Src: PStream; const Count: TStrmSize ): TStrmSize;
Copies Count bytes from Src to Dst, but without any optimization. Unlike Stream2Stream function, it can be applied to very large streams. See also Stream2StreamExBufSz.

function Stream2StreamExBufSz( Dst, Src: PStream; const Count: TStrmSize; BufSz: DWORD ): TStrmSize;
Copies Count bytes from Src to Dst using buffer of given size, but without other optimizations. Unlike Stream2Stream function, it can be applied to very large streams

function Resource2Stream( DestStrm: PStream; Inst: HInst; ResName: PKOLChar; ResType: PKOLChar ): Integer;
Loads given resource to DestStrm. Useful for non-standard resources to load it into memory (use memory stream for such purpose). Use one of following resource types to pass as ResType:

RT_ACCELERATOR Accelerator table
RT_ANICURSOR Animated cursor
RT_ANIICON Animated icon
RT_BITMAP Bitmap resource
RT_CURSOR Hardware-dependent cursor resource
RT_DIALOG Dialog box
RT_FONT         Font resource
RT_FONTDIR Font directory resource
RT_GROUP_CURSOR Hardware-independent cursor resource
RT_GROUP_ICON Hardware-independent icon resource
RT_ICON         Hardware-dependent icon resource
RT_MENU         Menu resource
RT_MESSAGETABLE Message-table entry
RT_RCDATA Application-defined resource (raw data)
RT_STRING String-table entry
RT_VERSION Version resource

For example:

var MemStrm: PStream;
    JpgObj: PJpeg;
......
 MemStrm := NewMemoryStream;
 JpgObj := NewJpeg;
......
 Resource2Stream( MemStrm, hInstance, 'MYJPEG', RT_RCDATA );
 MemStrm.Position := 0;
 JpgObj.LoadFromStream( MemStrm );
 MemStrm.Free;
......

function NewStrList: PStrList;
Creates string list object.

function GetFileList( const dir: Ansistring ): PStrList;
By Alexander Shakhaylo. Returns list of file names of the given directory.

function WStrLen( W: PWideChar ): Integer;
Returns Length of null-terminated Unicode string.

function NewStrListEx: PStrListEx;
Creates extended string list object.

procedure WStrCopy( Dest, Src: PWideChar );
Copies null-terminated Unicode string (terminated null also copied).

procedure WStrLCopy( Dest, Src: PWideChar; MaxLen: Integer );
Copies null-terminated Unicode string (terminated null also copied).

function WStrCmp( W1, W2: PWideChar ): Integer;
Compares two null-terminated Unicode strings.

function WStrCmp_NoCase( W1, W2: PWideChar ): Integer;
Compares two null-terminated Unicode strings.

type PWStrList = ^ TWstrList;

function NewWStrList: PWStrList;
Creates new TWStrList object and returns a pointer to it.

function NewWStrListEx: PWStrListEx;
Creates new TWStrListEx objects and returns a pointer to it.

type TGraphicToolType =( gttBrush, gttFont, gttPen );
Graphic object types, mainly for internal use.

type PGraphicTool = ^ TGraphicTool;

type TOnGraphicChange = procedure( Sender: PGraphicTool ) of object;
An event mainly for internal use.

type TBrushStyle =( bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross );
Available brush styles.

type TFontStyles =( fsBold, fsItalic, fsUnderline, fsStrikeOut );
Available font styles.

type TFontStyle = set of TFontStyles;
Font style is representing as a set of XFontStyles.

type TFontPitch =( fpDefault, fpFixed, fpVariable );
Availabe font pitch values.

type TFontName = type string;
Font name is represented as a string.

type TFontCharset = 0 . . 255;
Font charset is represented by number from 0 to 255.

type TFontQuality =( fqDefault, fqDraft, fqProof, fqNonAntialiased, fqAntialiased, fqClearType );
Font quality.

type TPenStyle =( psSolid, psDash, psDot, psDashDot, psDashDotDot, psClear, psInsideFrame );
Available pen styles. For more info see Delphi or Win32 help files.

type TPenMode =( pmBlack, pmNotMerge, pmMaskNotPen, pmNotCopy, pmMaskPenNot, pmNot, pmXor, pmNotMask, pmMask, pmNotXor, pmNop, pmMergePenNot, pmCopy, pmMergeNotPen, pmMerge, pmWhite );
Available pen modes. For more info see Delphi or Win32 help files.

type TPenEndCap =( pecRound, pecSquare, pecFlat );
Avalable (for geometric pen) end cap styles.

type TPenJoin =( pjRound, pjBevel, pjMiter );
Available (for geometric pen) join styles.

function Color2RGB( Color: TColor ): TColor;
Function to get RGB color from system color. Parameter can be also RGB color, in that case result is just equal to a parameter.

function RGB2BGR( Color: TColor ): TColor;
Converts RGB color to BGR

function ColorsMix( Color1, Color2: TColor ): TColor;
Returns color, which RGB components are build as an (approximate) arithmetic mean of correspondent RGB components of both source colors (these both are first converted from system to RGB, and result is always RGB color). Please note: this function is fast, but can be not too exact.

function Color2RGBQuad( Color: TColor ): TRGBQuad;
Converts color to RGB, used to represent RGB values in palette entries (actually swaps R and B bytes).

function Color2Color16( Color: TColor ): WORD;
Converts Color to RGB, packed to word (as it is used in format pf16bit).

function Color2Color15( Color: TColor ): WORD;
Converts Color to RGB, packed to word (as it is used in format pf15bit).

var DefFontColor: TColor = clWindowText;
Default font color.

var GlobalGraphics_UseFontOrient: Boolean;
Global flag. If stays False (default), Orientation property of Font objects is ignored. This flag is set to True automatically in RotateFonts add-on.

function NewFont: PGraphicTool;
Creates and returns font graphic tool object.

function NewBrush: PGraphicTool;
Creates and returns new brush object.

function NewPen: PGraphicTool;
Creates and returns new pen object.

type TFillStyle =( fsSurface, fsBorder );
Available filling styles. For more info see Win32 or Delphi help files.

type TFillMode =( fmAlternate, fmWinding );
Available filling modes. For more info see Win32 or Delphi help files.

type TCopyMode = Integer;
Available copying modes are following: cmBlackness
cmDstInvert
cmMergeCopy
cmMergePaint
cmNotSrcCopy
cmNotSrcErase
cmPatCopy
cmPatInvert
cmPatPaint
cmSrcAnd
cmSrcCopy
cmSrcErase
cmSrcInvert
cmSrcPaint
cmWhiteness
    Also it is possible to use any other available ROP2 modes. For more info, see Win32 help files.

type PCanvas = ^ TCanvas;

type TOnGetHandle = function( Canvas: PCanvas ): HDC of object;
For internal use mainly.

type TOnTextArea = procedure( Sender: PCanvas; var Size: TSize; var P0: TPoint );
Event to calculate actual area, occupying by a text. It is used to optionally extend calculating of TextArea taking into considaration font Orientation property.

function NewCanvas( DC: HDC ): PCanvas;
Use to construct Canvas on base of memory DC.

var GlobalCanvas_OnTextArea: TOnTextArea;
Global event to extend Canvas with possible add-ons, applied when rotated fonts are used only (to take into consideration Font.Orientation property in TextArea method).

type TImageListColors =( ilcColor, ilcColor4, ilcColor8, ilcColor16, ilcColor24, ilcColor32, ilcColorDDB, ilcDefault );
ImageList color schemes available.

type TDrawingStyles =( dsBlend25, dsBlend50, dsMask, dsTransparent );
ImageList drawing styles available.

type TDrawingStyle = Set of TDrawingStyles;
Style of drawing is a combination of all available drawing styles.

type TImageType =( itBitmap, itIcon, itCursor );
ImageList types available.

type PImageList = ^ TImageList;

type TPixelFormat =( pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom );
Available pixel formats.

type TBitmapHandleType =( bmDIB, bmDDB );
Available bitmap handle types.

function NewBitmap( W, H: Integer ): PBitmap;
Creates bitmap object of given size. If it is possible, do not change its size (Width and Heigth) later - this can economy code a bit. See TBitmap.

function NewDIBBitmap( W, H: Integer; PixelFormat: TPixelFormat ): PBitmap;
Creates DIB bitmap object of given size and pixel format. If it is possible, do not change its size (Width and Heigth) later - this can economy code a bit. See TBitmap.

function CalcScanLineSize( Header: PBitmapInfoHeader ): Integer;
May be will be useful.

function LoadMappedBitmap( hInst: THandle; BmpResID: Integer; const Map: array of TColor ): HBitmap;
This function can be used to load bitmap and replace some it colors to desired ones. This function especially useful when loaded by the such way bitmap is used as toolbar bitmap - to replace some original colors to system default colors. To use this function properly, the bitmap shoud be prepared as 16-color bitmap, which uses only system colors. To do so, create a new 16-color bitmap with needed dimensions in Borland Image Editor and paste a bitmap image, copyed in another graphic tool, and then save it. If this is not done, bitmap will not be loaded correctly!

function LoadMappedBitmapEx( MasterObj: PObj; hInst: THandle; BmpResName: PKOLChar; const Map: array of TColor ): HBitmap;
by Alex Pravdin: like LoadMappedBitmap, but much powerful. It uses CreateMappedBitmapEx, so it understands any bitmap color format, including pf24bit. Also, LoadMappedBitmapEx provides auto-destroying loaded resource when MasterObj is destroyed.

function CreateMappedBitmap( Instance: THandle; Bitmap: Integer; Flags: UINT; ColorMap: PColorMap; NumMaps: Integer ): HBitmap; stdcall;
Creates mapped bitmap replacing colors correspondently to the ColorMap (each pare of colors defines color replaced and a color used for replace it in the bitmap). See also CreateMappedBitmapEx.

function CreateMappedBitmapEx( Instance: THandle; BmpRsrcName: PKOLChar; Flags: Cardinal; ColorMap: PColorMap; NumMaps: Integer ): HBitmap;
By Alex Pravdin. Creates mapped bitmap independently from bitmap color format (works correctly with bitmaps having format deeper than 8bit per pixel).

procedure SaveIcons2Stream( const Icons: array of PIcon; Strm: PStream );
Saves several icons (of different dimentions) to stream.

function SaveIcons2StreamEx( const BmpHandles: array of HBitmap; Strm: PStream ): Boolean;
Saves icons creating it from pairs of bitmaps and their masks. BmpHandles array must contain pairs of bitmap handles, each pair of color bitmap and mask bitmap of the same size.

procedure SaveIcons2File( const Icons: array of PIcon; const FileName: KOLString );
Saves several icons (of different dimentions) to file. (Single file with extension .ico can contain several different sized icon images to use later one with the most appropriate size).

function NewIcon: PIcon;
Creates new icon object, setting its Size to 32 by default. Created icon is Empty.

function GetFileIconCount( const FileName: KOLString ): Integer;
Returns number of icon resources stored in given (executable) file.

function LoadImgIcon( RsrcName: PKOLChar; Size: Integer ): HIcon;
Loads icon of specified size from the resource.

var ID_SELF: array[ 0 . . 5 ] of KOLChar =( 'S', 'E', 'L', 'F', '_', #0 );
Identifier for window property "Self", stored directly in window, when it is created. This property is used to [fast] find TControl object, correspondent to given window handle (using API call GetProp).

var ID_PREVPROC: array[ 0 . . 9 ] of KOLChar =( 'P', 'R', 'E', 'V', '_', 'P', 'R', 'O', 'C', #0 );

type PControl = ^ TControl;
Type of pointer to TControl visual object. All constructing functions New[ControlName] are returning pointer of this type. Do not forget about some difference of using objects from using classes. Identifier Self for methods of object is not of pointer type, and to pass pointer to Self, it is necessary to pass @Self instead. At the same time, to use pointer to object in 'WITH' operator, it is necessary to apply suffix '^' to pointer to get know to compiler, what do You want.

type TWindowFunc = function( Sender: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean;
Event type to define custom extended message handlers (as pointers to procedure entry points). Such handlers are usually defined like add-ons, extending behaviour of certain controls and attached using AttachProc method of TControl. If the handler detects, that it is necessary to stop further message processing, it should return True.

type TMouseButton =( mbNone, mbLeft, mbRight, mbMiddle );
Available mouse buttons. mbNone is useful to get know, that there were no mouse buttons pressed.

type TMouseEventData = packed Record
Record to pass it to mouse handling routines, assigned to OnMouseXXXX events.
  Button: TMouseButton;
  StopHandling: Boolean; Set it to True in OnMouseXXXX event handler to
  R1, R2: Byte; Not used
  Shift : DWORD; HiWord( Shift ) = zDelta in WM_MOUSEWHEEL
  X, Y : SmallInt;
end;

type TOnMouse = procedure( Sender: PControl; var Mouse: TMouseEventData ) of object;
Common mouse handling event type.

type TOnKey = procedure( Sender: PControl; var Key: Longint; Shift: DWORD ) of object;
Key events. Shift is a combination of flags MK_SHIFT, MK_CONTROL, MK_ALT. (See GetShiftState funtion).

type TOnChar = procedure( Sender: PControl; var Key: KOLChar; Shift: DWORD ) of object;
Char event. Shift is a combination of flags MK_SHIFT, MK_CONTROL, MK_ALT.

type TTabKey =( tkTab, tkLeftRight, tkUpDown, tkPageUpPageDn );
Available tabulating key groups.

type TTabKeys = Set of TTabKey;
Set of tabulating key groups, allowed to be used in with a control (are installed by TControl.LookTabKey property).

type TOnMessage = function( var Msg: TMsg; var Rslt: Integer ): Boolean of object;
Event type for events, which allows to extend behaviour of windowed controls descendants using add-ons.

type TOnEventAccept = procedure( Sender: PObj; var Accept: Boolean ) of object;
Event type for OnClose event.

type TCloseQueryReason =( qClose, qShutdown, qLogoff );
Request reason type to call OnClose and OnQueryEndSession.

type TWindowState =( wsNormal, wsMinimized, wsMaximized );
Avalable states of TControl's window object.

type TOnSplit = function( Sender: PControl; NewSize1, NewSize2: Integer ): Boolean of object;
Event type for OnSplit event handler, designed specially for splitter control. Event handler must return True to accept new size of previous (to splitter) control and new size of the rest of client area of parent.

type TOnTVBeginDrag = procedure( Sender: PControl; Item: THandle ) of object;
Event type for OnTVBeginDrag event (defined for tree view control).

type TOnTVBeginEdit = function( Sender: PControl; Item: THandle ): Boolean of object;
Event type for OnTVBeginEdit event (for tree view control).

type TOnTVEndEdit = function( Sender: PControl; Item: THandle; const NewTxt: KOL_String ): Boolean of object;
Event type for TOnTVEndEdit event.

type TOnTVExpanding = function( Sender: PControl; Item: THandle; Expand: Boolean ): Boolean of object;
Event type for TOnTVExpanding event.

type TOnTVExpanded = procedure( Sender: PControl; Item: THandle; Expand: Boolean ) of object;
Event type for OnTVExpanded event.

type TOnTVDelete = procedure( Sender: PControl; Item: THandle ) of object;
Event type for OnTVDelete event.

type TOnTVSelChanging = function( Sender: PControl; oldItem, newItem: THandle ): Boolean of object;
When the handler returns False, selection is not changed.

type TOnDrag = function( Sender: PControl; ScrX, ScrY: Integer; var CursorShape: Integer; var Stop: Boolean ): Boolean of object;
Event, called during dragging operation (it is initiated with method Drag, where callback function of type TOnDrag is passed as a parameter). Callback function receives Stop parameter True, when operation is finishing. Otherwise, it can set it to True to force finishing the operation (in such case, returning False means cancelling drag operation, True - successful drag and in this last case callback is no more called). During the operation, when input Stop value is False, callback function can control Cursor shape, and return True, if the operation can be finished successfully at the given ScrX, ScrY position. ScrX, ScrY are screen coordinates of the mouse cursor.

type TCreateParams = packed record
Record to pass it through CreateSubClass method.
  Caption: PKOLChar;
  Style: cardinal;
  ExStyle: cardinal;
  X, Y: Integer;
  Width, Height: Integer;
  WndParent: HWnd;
  Param: Pointer;
  WindowClass: TWndClass;
  WinClassName: array[0.array.63] of KOLChar;
end;

type TTextAlign =( taLeft, taRight, taCenter );
Text alignments available.

type TRichTextAlign =( raLeft, raRight, raCenter, raJustify, raInterLetter, raScaled, raGlyphs, raSnapGrid );
Text alignment styles, available for RichEdit control.

type TVerticalAlign =( vaCenter, vaTop, vaBottom );
Vertical alignments available.

type TControlAlign =( caNone, caLeft, caTop, caRight, caBottom, caClient );
Control alignments available.

type TBitBtnOption =( bboImageList, bboNoBorder, bboNoCaption, bboFixed, bboFocusRect );
Options available for NewBitBtn.

type TBitBtnOptions = set of TBitBtnOption;
Set of options, available for NewBitBtn.

type TGlyphLayout =( glyphLeft, glyphTop, glyphRight, glyphBottom, glyphOver );
Layout of glyph (for NewBitBtn). Layout glyphOver means that text is drawn over glyph.

type TOnBitBtnDraw = function( Sender: PControl; BtnState: Integer ): Boolean of object;
Event type for TControl.OnBitBtnDraw event (which is called just before drawing the BitBtn). If handler returns True, there are no drawing occure. BtnState, passed to a handler, determines current button state and can be following: 0 - not pressed, 1 - pressed, 2 - disabled, 3 - focused. Value 4 is reserved for highlight state (then mouse is over it), but highlighting is provided only if property Flat is set to True (or one of events OnMouseEnter / OnMouseLeave is assigned to something).

type TListViewStyle =( lvsIcon, lvsSmallIcon, lvsList, lvsDetail, lvsDetailNoHeader );
Styles of view for ListView control (see NewListVew).

type TOnEditLVItem = function( Sender: PControl; Idx, Col: Integer; NewText: PKOL_Char ): Boolean of object;
Event type for OnEndEditLVItem. Return True in handler to accept new text value.

type TOnDeleteLVItem = procedure( Sender: PControl; Idx: Integer ) of object;
Event type for OnDeleteLVItem event.

type TOnLVData = procedure( Sender: PControl; Idx, SubItem: Integer; var Txt: KOL_String; var ImgIdx: Integer; var State: DWORD; var Store: Boolean ) of object;
Event type for OnLVData event. Used to provide virtual list view control (i.e. having lvoOwnerData style) with actual data on request. Use parameter Store as a flag if control should store obtained data by itself or not.

type TOnCompareLVItems = function( Sender: PControl; Idx1, Idx2: Integer ): Integer of object;
Event type to compare two items of the list view (while sorting it).

type TOnLVColumnClick = procedure( Sender: PControl; Idx: Integer ) of object;
Event type for OnColumnClick event.

type TOnLVStateChange = procedure( Sender: PControl; IdxFrom, IdxTo: Integer; OldState, NewState: DWORD ) of object;
Event type for OnLVStateChange event, called in responce to select/unselect a single item or items range in list view control).

type TDrawStates =( odsSelected, odsGrayed, odsDisabled, odsChecked, odsFocused, odsDefault, odsHotlist, odsInactive, odsNoAccel, odsNoFocusRect, ods400reserved, ods800reserved, odsComboboxEdit, odsMarked, odsIndeterminate );
Possible draw states.
odsSelected - The menu item's status is selected.
odsGrayed - The item is to be grayed. This bit is used only in a menu.
odsDisabled - The item is to be drawn as disabled.
odsChecked - The menu item is to be checked. This bit is used only in a menu.
odsFocused - The item has the keyboard focus.
odsDefault - The item is the default item.
odsHotList - Windows 98, Windows 2000: The item is being hot-tracked, that is, the item will be highlighted when the mouse is on the item.
odsInactive - Windows 98, Windows 2000: The item is inactive and the window associated with the menu is inactive.
odsNoAccel - Windows 2000: The control is drawn without the keyboard accelerator cues.
odsNoFocusRect - Windows 2000: The control is drawn without focus indicator cues.
odsComboboxEdit - The drawing takes place in the selection field (edit control) of an owner-drawn combo box.
odsMarked - for Common controls only. The item is marked. The meaning of this is up to the implementation.
odsIndeterminate - for Common Controls only. The item is in an indeterminate state.

type TDrawState = Set of TDrawStates;
Set of possible draw states.

type TOnDrawItem = function( Sender: PObj; DC: HDC; const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction; ItemState: TDrawState ): Boolean of object;
Event type for OnDrawItem event (applied to list box, combo box, list view).

type TOnMeasureItem = function( Sender: PObj; Idx: Integer ): Integer of object;
Event type for OnMeasureItem event. The event handler must return height of list box item as a result.

type TGetLVItemPart =( lvipBounds, lvipIcon, lvipLabel, lvupIconAndLabel );

type TWherePosLVItem =( lvwpOnIcon, lvwpOnLabel, lvwpOnStateIcon, lvwpOnColumn, lvwpOnItem );

type TOnLVCustomDraw = function( Sender: PControl; DC: HDC; Stage: DWORD; ItemIdx, SubItemIdx: Integer; const Rect: TRect; ItemState: TDrawState; var TextColor, BackColor: TColor ): DWORD of object;
Event type for OnLVCustomDraw event.

type TGradientStyle =( gsVertical, gsHorizontal, gsRectangle, gsElliptic, gsRombic, gsTopToBottom, gsBottomToTop );
Gradient fill styles. See also TGradientLayout.

type TGradientLayout =( glTopLeft, glTop, glTopRight, glLeft, glCenter, glRight, glBottomLeft, glBottom, glBottomRight );
Position of starting line / point for gradient filling. Depending on TGradientStyle, means either position of first line of first rectangle (ellipse) to be expanded in a loop to fit entire gradient panel area.

type TEditOption =( eoNoHScroll, eoNoVScroll, eoLowercase, eoMultiline, eoNoHideSel, eoOemConvert, eoPassword, eoReadonly, eoUpperCase, eoWantReturn, eoWantTab, eoNumber );
Available edit options.
Please note, that eoWantTab option just removes TAB key from a list of keys available to tabulate from the edit control. To provide insertion of tabulating key, do so in TControl.OnChar event handler. Sorry for inconvenience, but this is because such behaviour is not must in all cases. See also TControl.EditTabChar property.

type TEditOptions = Set of TEditOption;
Set of available edit options.

type TRichFmtArea =( raSelection, raWord, raAll );
Characters formatting area for RichEdit.

type TRETextFormat =( reRTF, reText, rePlainRTF, reRTFNoObjs, rePlainRTFNoObjs, reTextized, reUnicode, reTextUnicode );
Available formats for transfer RichEdit text using property TControl.RE_Text.

reRTF - normal rich text (no transformations)
reText - plain text only (without OLE objects)
reTextized - plain text with text representation of COM objects
rePlainRTF - reRTF without language-specific keywords
reRTFNoObjs - reRTF without OLE objects
rePlainRTFNoObjs - rePlainRTF without OLE objects
reUnicode - stream is 2-byte Unicode characters rather then 1-byte Ansi

type TRichUnderline =( ruSingle, ruWord, ruDouble, ruDotted, ruDash, ruDashDot, ruDashDotDot, ruWave, ruThick, ruHairLine );
Rich text exteded underline styles (available only for RichEdit v2.0, and even for RichEdit v2.0 additional styles can not displayed - but ruDotted under Windows2000 is working).

type TRichTextSizes =( rtsNoUseCRLF, rtsNoPrecise, rtsClose, rtsBytes );
Options to calculate size of rich text. Available only for RichEdit2.0 or higher.

type TRichTextSize = set of TRichTextSizes;
Set of all available optioins to calculate rich text size using property TControl.RE_TextSize[ options ].

type TRichNumbering =( rnNone, rnBullets, rnArabic, rnLLetter, rnULetter, rnLRoman, rnURoman );
Advanced numbering styles for paragraph (RichEdit).

rnNone     - no numbering
rnBullets  - bullets only
rnArabic   - 1, 2, 3, 4, ...
rnLLetter  - a, b, c, d, ...
rnULetter  - A, B, C, D, ...
rnLRoman   - i, ii, iii, iv, ...
rnURoman   - I, II, III, IV, ...
rnNoNumber - do not show any numbers (but numbering is taking place).

type TRichNumBrackets =( rnbRight, rnbBoth, rnbPeriod, rnbPlain, rnbNoNumber );
Brackets around number:

rnbRight   - 1) 2) 3)     - this is default !
rnbBoth    - (1) (2) (3)
rnbPeriod  - 1. 2. 3.
rnbPlain   - 1 2 3

type TBorderEdge =( beLeft, beTop, beRight, beBottom );
Borders of rectangle.

type TOnTestMouseOver = function( Sender: PControl ): Boolean of object;
Event type for TControl.OnTestMouseOver event. The handler should return True, if it dectects, that mouse is over control.

type TEdgeStyle =( esRaised, esLowered, esNone, esTransparent, esSolid );
Edge styles (for panel - see NewPanel). esTransparent and esSolid - special styles equivalent to esNone except GRushControls are used via USE_GRUSH symbol (ToGRush.pas)

type TListOption =( loNoHideScroll, loNoExtendSel, loMultiColumn, loMultiSelect, loNoIntegralHeight, loNoSel, loSort, loTabstops, loNoStrings, loNoData, loOwnerDrawFixed, loOwnerDrawVariable, loHScroll );
Options for ListBox (see NewListbox). To use loHScroll, you also have to send LB_SETHORIZONTALEXTENT with a maximum width of a line in pixels (wParam)!

type TListOptions = Set of TListOption;
Set of available options for Listbox.

type TComboOption =( coReadOnly, coNoHScroll, coAlwaysVScroll, coLowerCase, coNoIntegralHeight, coOemConvert, coSort, coUpperCase, coOwnerDrawFixed, coOwnerDrawVariable, coSimple );
Options for combobox.

type TComboOptions = Set of TComboOption;
Set of options available for combobox.

type TProgressbarOption =( pboVertical, pboSmooth );
Options for progress bar.

type TProgressbarOptions = set of TProgressbarOption;
Set of options available for progress bar.

type TTreeViewOption =( tvoNoLines, tvoLinesRoot, tvoNoButtons, tvoEditLabels, tvoHideSel, tvoDragDrop, tvoNoTooltips, tvoCheckBoxes, tvoTrackSelect, tvoSingleExpand, tvoInfoTip, tvoFullRowSelect, tvoNoScroll, tvoNonEvenHeight );
Tree view options.

type TTreeViewOptions = set of TTreeViewOption;
Set of tree view options.

type TTabControlOption =( tcoButtons, tcoFixedWidth, tcoFocusTabs, tcoIconLeft, tcoLabelLeft, tcoMultiline, tcoMultiselect, tcoFitRows, tcoScrollOpposite, tcoBottom, tcoVertical, tcoFlat, tcoHotTrack, tcoBorder, tcoOwnerDrawFixed );
Options, available for TabControl.

type TTabControlOptions = set of TTabControlOption;
Set of options, available for TAbControl during its creation (by NewTabControl function).

type TToolbarOption =( tboTextRight, tboTextBottom, tboFlat, tboTransparent, tboWrapable, tboNoDivider, tbo3DBorder, tboCustomErase );
Toolbar options. When tboFlat is set and toolbar is placed onto panel, set its property Transparent to TRUE to provide its correct view.

type TToolbarOptions = Set of TToolbarOption;
Set of toolbar options.

type TOnToolbarButtonClick = procedure( Sender: PControl; BtnID: Integer ) of object;
Special event type to handle separate toolbar buttons click events.

type TOnTBCustomDraw = function( Sender: PControl; var NMCD: TNMTBCustomDraw ): Integer of object;
Event type for OnTBCustomDraw event.

type TDateTimePickerOption =( dtpoTime, dtpoDateLong, dtpoUpDown, dtpoRightAlign, dtpoShowNone, dtpoParseInput );

type TDateTimePickerOptions = set of TDateTimePickerOption;

type TDTParseInputEvent = procedure( Sender: PControl; const UserString: Ansistring; var DateAndTime: TDateTime; var AllowChange: Boolean ) of object;

type TOnDropFiles = procedure( Sender: PControl; const FileList: KOL_String; const Pt: TPoint ) of object;
An event type for OnDropFiles event. When the event is occur, FileList parameter contains a list of files dropped. File names in a list are separated with #13 character. This allows You to assign it to TStrList object using its property Text (for example):

 procedure TSomeObject.DropFiles( Sender: PControl; const FileList: AnsiString;
           const Pt: TPoint ); )
 var FList: PStrList;
     I: Integer;
 begin
   FList := NewStrList;
   FList.Text := FileList;
   for I := 0 to FList.Count-1 do
   begin
     // do something with FList.Items[ I ]
   end;
   FList.Free;
 end;

function ToolbarButtonRect( Toolbar: PControl; BtnID: Integer ): TRect;
Use this function instead of reading TControl.TBButtonRect, if you want to have it working the same way when standard toolbar is used or GRushControl toolbar provided in ToGRush.pas unit.

procedure ToolbarSetTooltips( Toolbar: PControl; BtnID1st: Integer; const Tooltips: array of PKOLChar );
Use this function instead of TContol.TBSetTooltips in your project, when you use ToGRush unit.

function ToolbarButtonEnabled( Toolbar: PControl; BtnID: Integer ): Boolean;
Use this function instead of reading the property TControl.TBButtonEnabled when tou use ToGRush unit.

procedure EnableToolbarButton( Toolbar: PControl; BtnID: Integer; Enable: Boolean );
Use this procedure instead of writing the property TControl.TBButtonEnabled when you use ToGRush unit.

function ToolbarButtonVisible( Toolbar: PControl; BtnID: Integer ): Boolean;
Use this function instead of reading the property TControl.TBButtonVisible when tou use ToGRush unit.

procedure ShowHideToolbarButton( Toolbar: PControl; BtnID: Integer; Show: Boolean );
Use this procedure instead of writing the property TControl.TBButtonVisible when you use ToGRush unit.

function ToolbarButtonChecked( Toolbar: PControl; BtnID: Integer ): Boolean;

procedure ToolbarButtonSetChecked( Toolbar: PControl; BtnID: Integer; Checked: Boolean );

type TOnPaintBkgnd = procedure( Sender: PControl; DC: HDC; Rect: PRect );
Global event definition. Used to define Global_OnPaintBackground event placeholder.

var Global_OnPaintBkgnd: TOnPaintBkgnd = DefaultPaintBackground;
Global event. It is assigned in XBackgounds.pas add-on to replace PaintBackground method for all TVisual objects, allowing great visualization effect: transparent controls over [animated] bitmap background. Idea: Wei Bao. Implementation: Kladov Vladimir.

function GetShiftState: DWORD;
Returns shift state.

function AutoMinimizeApplet( Self_: PControl; var Msg: TMsg; var Rslt: Integer ): Boolean;
By Sergey Shishmintzev. Attach this handler to your modal dialog form handle to provide automatic minimization of all other forms in the application together with the dialog.

var HelpFilePath: PAnsiChar;
Path to application help file. If not assigned, application path with extension replaced to '.hlp' used. To use '.chm' file (HtmlHelp), call AssignHtmlHelp with a path to a html help file (or a name).

procedure HtmlHelpCommand( Wnd: HWnd; const HelpFilePath: AnsiString; Cmd, Data: Integer );
Use this wrapper procedure to call HtmlHelp API function.

type THHNNotify = tagHHN_NOTIFY;
* Use by command HH_DISPLAY_TEXT_POPUP

type THHPopup = tagHH_POPUP;
* Use by commands - HH_ALINK_LOOKUP, HH_KEYWORD_LOOKUP

var Global_GetCtlBrushHandle: function( Sender: PControl ): HBrush = SimpleGetCtlBrushHandle;
Is called to obtain brush handle.

var Global_Align: procedure( Sender: PObj ) = DummyObjProc;
Is set to perform aligning of control, and only if property Align is changed for TControl, or SetAlign method is called for it.

function WndFunc( W: HWnd; Msg: Cardinal; wParam, lParam: Integer ): Integer; stdcall;
Global message handler for window. Redirects all messages to destination windows, obtaining target TControl object address from window itself, using GetProp API call.

var AppletRunning: Boolean;
Is set to True while message loop is processing (in Run procedure).

var AppletTerminated: Boolean;
Is set to True when message loop is terminated.

var Applet: PControl;
Applet window object. Actually, can be set to main form if program not needed in special applet button window (useful to make applet button invisible on taskbar, or to have several forms with single applet button - crete it in that case using NewApplet).

var AppButtonUsed: Boolean;
True if special window to represent applet button (may be invisible) is used. If no, every form is represented with its own taskbar button (always visible).

var ScreenCursor: HCursor;
Set this global variable to override any cursor settings of current form or control.

function ScreenWidth: Integer;
Returns screen width in pixels.

function ScreenHeight: Integer;
Returns screen height in pixels.

type TStatusOption =( soNoSizeGrip, soTop );
Options available for status bars.

type TStatusOptions = Set of TStatusOption;
Status bar options.

procedure DrawFormattedText( Ctl: PControl; DC: HDC; var R: TRect; Flags: DWORD );
This procedure can be useful to draw control's text in custom-defined controls.

procedure DrawFormattedTextXP( Theme: THandle; Ctl: PControl; DC: HDC; var R: TRect; CtlType, CtlStates, Flags1, Flags2: Integer );
This procedure can be useful to draw control's text in custom-defined controls.

function _NewGraphCtl( AParent: PControl; ATabStop: Boolean ): PControl;
Creates graphic control basics.

function NewGraphLabel( AParent: PControl; const ACaption: AnsiString ): PControl;
Creates graphic label, which does not require a window handle.

function NewWordWrapGraphLabel( AParent: PControl; const ACaption: KOLString ): PControl;
Creates graphic label, which does not require a window handle.

function NewGraphPaintBox( AParent: PControl ): PControl;
Creates graphic paint box (just the same as graphic label, but with empty Caption).

function NewGraphCheckBox( AParent: PControl; const ACaption: KOLString ): PControl;
Creates graphic checkbox.

function NewGraphRadioBox( AParent: PControl; const ACaption: KOLString ): PControl;
Creates graphic radiobox.

function NewGraphButton( AParent: PControl; const ACaption: KOLString ): PControl;
Creates graphic button.

function NewGraphEditbox( AParent: PControl; Options: TEditOptions ): PControl;
Creates graphic edit box. To do editing, this box should be replaced with real edit box with a handle (actually, it is enough to place an edit box on the same Parent having the same BoundsRect).

procedure Run( var AppletWnd: PControl );
Call this procedure to process messages loop of your program. Pass here pointer to applet button object (if You have created it - see NewApplet) or your main form object of type PControl (created using NewForm).

Visual objects constructing functions

Following constructing functions for visual controls are available:
NewAppletfunction NewApplet( const Caption: KOLString ): PControl;
NewFormfunction NewForm( AParent: PControl; const Caption: KOLString ): PControl;
NewButtonfunction NewButton( AParent: PControl; const Caption: KOLString ): PControl;
NewBitBtnfunction NewBitBtn( AParent: PControl; const Caption: KOLString; Options: TBitBtnOptions; Layout: TGlyphLayout; GlyphBitmap: HBitmap; GlyphCount: Integer ): PControl;
NewLabelfunction NewLabel( AParent: PControl; const Caption: KOLString ): PControl;
NewWordWrapLabelfunction NewWordWrapLabel( AParent: PControl; const Caption: KOLString ): PControl;
NewLabelEffectfunction NewLabelEffect( AParent: PControl; const Caption: KOLString; ShadowDeep: Integer ): PControl;
NewPaintboxfunction NewPaintbox( AParent: PControl ): PControl;
NewImageShowfunction NewImageShow( AParent: PControl; AImgList: PImageList; ImgIdx: Integer ): PControl;
NewScrollBarfunction NewScrollBar( AParent: PControl; BarSide: TScrollerBar ): PControl;
NewScrollBoxfunction NewScrollBox( AParent: PControl; EdgeStyle: TEdgeStyle; Bars: TScrollerBars ): PControl;
NewScrollBoxExfunction NewScrollBoxEx( AParent: PControl; EdgeStyle: TEdgeStyle ): PControl;
NewGradientPanelfunction NewGradientPanel( AParent: PControl; Color1, Color2: TColor ): PControl;
NewGradientPanelExfunction NewGradientPanelEx( AParent: PControl; Color1, Color2: TColor; Style: TGradientStyle; Layout: TGradientLayout ): PControl;
NewPanelfunction NewPanel( AParent: PControl; EdgeStyle: TEdgeStyle ): PControl;
NewMDIClientfunction NewMDIClient( AParent: PControl; WindowMenu: THandle ): PControl;
NewMDIChildfunction NewMDIChild( AParent: PControl; const ACaption: KOLString ): PControl;
NewSplitterfunction NewSplitter( AParent: PControl; MinSizePrev, MinSizeNext: Integer ): PControl;
NewSplitterExfunction NewSplitterEx( AParent: PControl; MinSizePrev, MinSizeNext: Integer; EdgeStyle: TEdgeStyle ): PControl;
NewGroupboxfunction NewGroupbox( AParent: PControl; const Caption: KOLString ): PControl;
NewCheckboxfunction NewCheckbox( AParent: PControl; const Caption: KOLString ): PControl;
NewCheckBox3Statefunction NewCheckBox3State( AParent: PControl; const Caption: KOLString ): PControl;
NewRadioboxfunction NewRadiobox( AParent: PControl; const Caption: KOLString ): PControl;
NewEditboxfunction NewEditbox( AParent: PControl; Options: TEditOptions ): PControl;
NewRichEditfunction NewRichEdit( AParent: PControl; Options: TEditOptions ): PControl;
NewRichEdit1function NewRichEdit1( AParent: PControl; Options: TEditOptions ): PControl;
NewListboxfunction NewListbox( AParent: PControl; Options: TListOptions ): PControl;
NewComboboxfunction NewCombobox( AParent: PControl; Options: TComboOptions ): PControl;
NewProgressbarfunction NewProgressbar( AParent: PControl ): PControl;
NewProgressbarExfunction NewProgressbarEx( AParent: PControl; Options: TProgressbarOptions ): PControl;
NewListViewfunction NewListView( AParent: PControl; Style: TListViewStyle; Options: TListViewOptions; ImageListSmall, ImageListNormal, ImageListState: PImageList ): PControl;
NewTreeViewfunction NewTreeView( AParent: PControl; Options: TTreeViewOptions; ImgListNormal, ImgListState: PImageList ): PControl;
NewTabControlfunction NewTabControl( AParent: PControl; const Tabs: array of PKOLChar; Options: TTabControlOptions; ImgList: PImageList; ImgList1stIdx: Integer ): PControl;
NewTabEmptyfunction NewTabEmpty( AParent: PControl; Options: TTabControlOptions; ImgList: PImageList ): PControl;
NewToolbarfunction NewToolbar( AParent: PControl; Align: TControlAlign; Options: TToolbarOptions; Bitmap: HBitmap; const Buttons: array of PKOLChar; const BtnImgIdxArray: array of Integer ): PControl;
NewDateTimePickerfunction NewDateTimePicker( AParent: PControl; Options: TDateTimePickerOptions ): PControl;

procedure AppletMinimize;
Minimizes the application (Applet should be assigned to have effect).

procedure AppletHide;
Minimizes and hides application.

procedure AppletRestore;
Restores Applet when minimized.

procedure RegisterIdleHandler( const OnIdle: TOnEvent );
Registers new Idle handler. Idle handler is called each time when message queue becomes empty.

procedure UnRegisterIdleHandler( const OnIdle: TOnEvent );
Unregisters Idle handler.

procedure InitCommonControls; stdcall;

procedure DoInitCommonControls( dwICC: DWORD );
Calls extended initialization for Common Controls (from ComCtrl32). Pass one of following constants:

ICC_LISTVIEW_CLASSES   = $00000001; // listview, header
ICC_TREEVIEW_CLASSES   = $00000002; // treeview, tooltips
ICC_BAR_CLASSES        = $00000004; // toolbar, statusbar, trackbar, tooltips
ICC_TAB_CLASSES        = $00000008; // tab, tooltips
ICC_UPDOWN_CLASS       = $00000010; // updown
ICC_PROGRESS_CLASS     = $00000020; // progress
ICC_HOTKEY_CLASS       = $00000040; // hotkey
ICC_ANIMATE_CLASS      = $00000080; // animate
ICC_WIN95_CLASSES      = $000000FF;
ICC_DATE_CLASSES       = $00000100; // month picker, date picker, time picker, updown
ICC_USEREX_CLASSES     = $00000200; // comboex
ICC_COOL_CLASSES       = $00000400; // rebar (coolbar) control
ICC_INTERNET_CLASSES   = $00000800;
ICC_PAGESCROLLER_CLASS = $00001000; // page scroller
ICC_NATIVEFNTCTL_CLASS = $00002000; // native font control

function OleInit: Boolean;
Calls OleInitialize (once - all other calls are simulated by incrementing call counter. Every OleInit shoud be complemented with correspondent OleUninit. (Though, it is possible to call API function OleUnInitialize once to cancel all OleInit calls).

procedure OleUnInit;
Decrements counter and calls OleUnInitialize when it is zeroed.

function StringToOleStr( const Source: Ansistring ): PWideChar;

function NewApplet( const Caption: KOLString ): PControl;
Creates applet button window, which has to be parent of all other forms in your project (but this is *not must*). See also comments about NewForm.
Following methods, properties and events are useful to work with applet control:
Runprocedure Run( var AppletWnd: PControl );
OnMessageproperty OnMessage: TOnMessage;
Closeprocedure Close;
IconLoadprocedure IconLoad( Inst: Integer; ResName: PKOLChar );
IconLoadCursorprocedure IconLoadCursor( Inst: Integer; ResName: PKOLChar );
Showprocedure Show;
Hideprocedure Hide;
IsMainWindowfunction IsMainWindow: Boolean;
ProcessMessagefunction ProcessMessage: Boolean;
ProcessMessagesprocedure ProcessMessages;
ProcessPendingMessagesprocedure ProcessPendingMessages;
Iconproperty Icon: HIcon;
Captionproperty Caption: KOLString;
ModalFormproperty ModalForm: PControl;

function NewForm( AParent: PControl; const Caption: KOLString ): PControl;
Creates form window object and returns pointer to it. If You use only one form, and You are not going to do applet button on task bar invisible, it is not necessary to create also special applet button window - just pass your (main) form object to Run procedure. In that case, it is a good idea to assign pointer to your main form object to Applet variable immediately following creating it - because some objects (e.g. TTimer) want to have Applet assigned to something.
Following methods, properties and events are useful to work with forms (ones common for all visual objects, such as Left , Top , Width , Height , etc. are not listed here - look TControl for it):
OnMessageproperty OnMessage: TOnMessage;
OnCloseproperty OnClose: TOnEventAccept;
OnQueryEndSessionproperty OnQueryEndSession: TOnEventAccept;
OnMinimizeproperty OnMinimize: TOnEvent;
OnMaximizeproperty OnMaximize: TOnEvent;
OnRestoreproperty OnRestore: TOnEvent;
OnFormClickproperty OnFormClick: TOnEvent;
fModalResultfModalResult;
ParentFormfunction ParentForm: PControl;
CreateWindowfunction CreateWindow: Boolean; virtual;
Closeprocedure Close;
IconLoadprocedure IconLoad( Inst: Integer; ResName: PKOLChar );
IconLoadCursorprocedure IconLoadCursor( Inst: Integer; ResName: PKOLChar );
Showprocedure Show;
ShowModalfunction ShowModal: Integer;
Hideprocedure Hide;
MinimizeNormalAnimatedprocedure MinimizeNormalAnimated;
RestoreNormalMaximizedprocedure RestoreNormalMaximized;
IsMainWindowfunction IsMainWindow: Boolean;
GotoControlprocedure GotoControl( Key: DWORD );
RemoveStatusprocedure RemoveStatus;
StatusPanelCountfunction StatusPanelCount: Integer;
Iconproperty Icon: HIcon;
Captionproperty Caption: KOLString;
Modalproperty Modal: Boolean;
ModalFormproperty ModalForm: PControl;
WindowStateproperty WindowState: TWindowState;
HasBorderproperty HasBorder: Boolean;
HasCaptionproperty HasCaption: Boolean;
CanResizeproperty CanResize: Boolean;
StayOnTopproperty StayOnTop: Boolean;
Borderproperty Border: Integer;
Marginproperty Margin: Integer;
AlphaBlendproperty AlphaBlend: Byte;
StatusTextproperty StatusText[ Idx: Integer ]: PKOLChar;
SimpleStatusTextproperty SimpleStatusText: PKOLChar;
StatusPanelRightXproperty StatusPanelRightX[ Idx: Integer ]: Integer;
StatusWindowproperty StatusWindow: HWND;

function NewButton( AParent: PControl; const Caption: KOLString ): PControl;
Creates button on given parent control or form. Please note, that in Windows, buttons can not change its Font color and to be Transparent .
Following methods, properies and events are (especially) useful with a button:
OnClickproperty OnClick: TOnEvent;
SetButtonIconfunction SetButtonIcon( aIcon: HIcon ): PControl;
SetButtonBitmapfunction SetButtonBitmap( aBmp: HBitmap ): PControl;
LikeSpeedButtonfunction LikeSpeedButton: PControl;
Clickprocedure Click;
Captionproperty Caption: KOLString;
DefaultBtnproperty DefaultBtn: Boolean;
CancelBtnproperty CancelBtn: Boolean;
TextAlignproperty TextAlign: TTextAlign;
VerticalAlignproperty VerticalAlign: TVerticalAlign;

function NewBitBtn( AParent: PControl; const Caption: KOLString; Options: TBitBtnOptions; Layout: TGlyphLayout; GlyphBitmap: HBitmap; GlyphCount: Integer ): PControl;
Creates image button (actually implemented as owner-drawn). In Options, it is possible to determine, whether bitmap or image list used to contain one or more (up to 5) images, correspondent to certain BitBtn state.
    For case of imagelist (option bboImageList), it is possible to use a number of glyphs from the image list, starting from image index given by GlyphCount parameter. Number of used glyphs is passed in that case in high word of GlyphCount parameter (if 0, one image is used therefore). For bboImageList, BitBtn can be Transparent (and in that case bboNoBorder style can be useful to draw custom buttons of non-rectangular shape).
    For case of bitmap BitBtn, image is stretched down (if too big), but can not be transparent. It is not necessary for bitmap BitBtn to pass correct GlyphCount - it is calculated on base of bitmap size, if 0 is passed.
    And, certainly, BitBtn can be without glyph image (text only). For that case, it is therefore is more flexible and power than usual Button (but requires more code). E.g., BitBtn can change its
Font , Color , and to be totally Transparent . Moreover, BitBtn can be Flat , bboFixed, SpeedButton and have property RepeatInterval .
    Note: if You use bboFixed Style, use OnChange event instead of OnClick, because Checked state is changed immediately however OnClick occure only when mouse or space key released (and can be not called at all if mouse button is released out of BitBtn bounds). Also, bboFixed defines only which glyph to show (the border if it is not turned off behaves as usual for a button, i.e. it becomes lowered and then raised again at any click). Here You can find references to other properties, events and methods applicable to BitBtn:
OnBitBtnDrawproperty OnBitBtnDraw: TOnBitBtnDraw;
OnTestMouseOverproperty OnTestMouseOver: TOnTestMouseOver;
LikeSpeedButtonfunction LikeSpeedButton: PControl;
Captionproperty Caption: KOLString;
BitBtnDrawMnemonicproperty BitBtnDrawMnemonic: Boolean;
TextShiftXproperty TextShiftX: Integer;
TextShiftYproperty TextShiftY: Integer;
BitBtnImgIdxproperty BitBtnImgIdx: Integer;
BitBtnImgListproperty BitBtnImgList: THandle;
DefaultBtnproperty DefaultBtn: Boolean;
CancelBtnproperty CancelBtn: Boolean;
TextAlignproperty TextAlign: TTextAlign;
MouseInControlproperty MouseInControl: Boolean;
Flatproperty Flat: Boolean;
RepeatIntervalproperty RepeatInterval: Integer;
ImageListNormalproperty ImageListNormal: PImageList;

function NewLabel( AParent: PControl; const Caption: KOLString ): PControl;
Creates static text control (native Windows STATIC control). Use property Caption at run time to change label text. Also it is possible to adjust label Font , Brush or Color . Label can be Transparent . If You want to have rotated text label, call NewLabelEffect instead and change its Font .FontOrientation. Other references certain for a label:
Captionproperty Caption: KOLString;
TextAlignproperty TextAlign: TTextAlign;
VerticalAlignproperty VerticalAlign: TVerticalAlign;

function NewWordWrapLabel( AParent: PControl; const Caption: KOLString ): PControl;
Creates multiline static text control (native Windows STATIC control), which can wrap long text onto several lines. See also NewLabel. See also:
Captionproperty Caption: KOLString;

function NewLabelEffect( AParent: PControl; const Caption: KOLString; ShadowDeep: Integer ): PControl;
Creates 3D-label with capability to rotate its text Caption , which is controlled by changing Font .FontOrientation property. If You want to get flat effect label (e.g. to rotate it only), pass ShadowDeep = 0. Please note, that drawing procedure uses Canvas property, so using of LabelEffect leads to increase size of executable. See also:
Captionproperty Caption: KOLString;
ShadowDeepproperty ShadowDeep: Integer;

function NewPaintbox( AParent: PControl ): PControl;
Creates owner-drawn STATIC control. Set its OnPaint event to perform custom painting.
Canvasproperty Canvas: PCanvas;

function NewImageShow( AParent: PControl; AImgList: PImageList; ImgIdx: Integer ): PControl;
Creates an image show control, implemented as a paintbox which is used to draw an image from the imagelist. At run-time, use property CurIndex to select another image from the imagelist, and a property ImageListNormal to use another image list. When the control is created, its size becomes equal to dimensions of imagelist (if any).

function NewScrollBar( AParent: PControl; BarSide: TScrollerBar ): PControl;
Creates simple scroll bar.

function NewScrollBox( AParent: PControl; EdgeStyle: TEdgeStyle; Bars: TScrollerBars ): PControl;
Creates simple scrolling box, which can be used any way you wish, e.g. to scroll certain large image. To provide automatic scrolling of a set of child controls, use advanced scroll box, created with NewScrollBoxEx.

function NewScrollBoxEx( AParent: PControl; EdgeStyle: TEdgeStyle ): PControl;
Creates extended scrolling box control, which automatically scrolls child controls (if any).

function NewGradientPanel( AParent: PControl; Color1, Color2: TColor ): PControl;
Creates gradient-filled STATIC control. To adjust colors at the run time, change Color1 and Color2 properties (which initially are assigned from Color1, Color2 parameters), and call Invalidate method to repaint control.

function NewGradientPanelEx( AParent: PControl; Color1, Color2: TColor; Style: TGradientStyle; Layout: TGradientLayout ): PControl;
Creates gradient-filled STATIC control. To adjust colors at the run time, change Color1 and Color2 properties (which initially are assigned from Color1, Color2 parameters), and call Invalidate method to repaint control. Depending on style and first line/point layout, can looking different. Idea: Vladimir Stojiljkovic.

function NewPanel( AParent: PControl; EdgeStyle: TEdgeStyle ): PControl;
Creates panel, which can be parent for other controls (though, any control can be used as a parent for other ones, but panel is specially designed for such purpose).

function NewMDIClient( AParent: PControl; WindowMenu: THandle ): PControl;
Creates MDI client window, which is a special type of child window, containing all MDI child windows, created calling NewMDIChild function. On a form, MDI client behaves like a panel, so it can be placed and sized (or aligned) like any other controls. To minimize flick during resizing main form having another aligned controls, place MDI client window on a panel and align it caClient in the panel.
Note: MDI client must be a single on the form.

function NewMDIChild( AParent: PControl; const ACaption: KOLString ): PControl;
Creates MDI client window. AParent should be a MDI client window, created with NewMDIClient function.

function NewSplitter( AParent: PControl; MinSizePrev, MinSizeNext: Integer ): PControl;
Creates splitter control, which will separate previous one (i.e. last created one before splitter on the same parent) from created next, allowing to user to adjust size of separated controls by dragging the splitter in desired direction. Created splitter becomes vertical or horizontal depending on Align style of previous control on the same parent (if caLeft/caRight then vertical, if caTop/caBottom then horizontal).
    Please note, what if previous control has no Align equal to caLeft/caRight or caTop/caBottom, splitter will not be able to function normally. If previous control does not exist, it is yet possible to use splitter as a resizeable panel (but set its initial Align value first - otherwise it is not set by default. Also, change Cursor property as You wish in that case, since it is not set too in case, when previous control does not exist).
    Additional parameters determine, which minimal size (width or height - correspondently to split direction) is allowed for left (top) control and to rest of client area of parent, correspondently. (It is possible later to set second control for checking its size with MinSizeNext value - using
TControl.SecondControl property). If -1 passed, correspondent control size is not checked during dragging of splitter. Usually 0 is more suitable value (with this value, it is garantee, that splitter will be always available even if mouse was released far from the edge of form).
    It is possible for user to press Escape any time while dragging splitter to abort all adjustments made starting from left mouse button push and begin of drag the splitter. But remember please, that such event is controlled using timer, and therefore correspondent keyboard events are received by currently focused control. Be sure, that pressing Escape will not affect to any control on form, which could be focused, otherwise filter keyboard messages (by yourself) to prevent undesired handling of Escape key by certain controls while splitting. (Use Dragging property to check if splitter is dragging by user with mouse).
    See also: NewSplitterEx
OnSplitproperty OnSplit: TOnSplit;
MinSizePrevproperty MinSizePrev: Integer;
MinSizeNextproperty MinSizeNext: Integer;
SecondControlproperty SecondControl: PControl;
Draggingproperty Dragging: Boolean;

function NewSplitterEx( AParent: PControl; MinSizePrev, MinSizeNext: Integer; EdgeStyle: TEdgeStyle ): PControl;
Creates splitter control. Difference from NewSplitter is what it is possible to determine if a splitter will be beveled or not. See also NewSplitter.

function NewGroupbox( AParent: PControl; const Caption: KOLString ): PControl;
Creates group box control. Note, that to group radio items, group box is not necessary - any parent can play role of group for radio items. See also NewPanel.

function NewCheckbox( AParent: PControl; const Caption: KOLString ): PControl;
Creates check box control. Special properties, methods, events:
OnClickproperty OnClick: TOnEvent;
SetCheckedfunction SetChecked( const Value: Boolean ): PControl;
Clickprocedure Click;
Checkedproperty Checked: Boolean;
Check3property Check3: TTriStateCheck;

function NewCheckBox3State( AParent: PControl; const Caption: KOLString ): PControl;
Creates check box control with 3 states. Special properties, methods, events:
OnClickproperty OnClick: TOnEvent;
SetCheckedfunction SetChecked( const Value: Boolean ): PControl;
Clickprocedure Click;
Checkedproperty Checked: Boolean;
Check3property Check3: TTriStateCheck;

function NewRadiobox( AParent: PControl; const Caption: KOLString ): PControl;
Creates radio box control. Alternative radio items must have the same parent window (regardless of its kind, either groupbox (NewGroupbox), panel (NewPanel) or form itself). Following properties, methods and events are specially for radiobox controls:
OnClickproperty OnClick: TOnEvent;
SetRadioCheckedfunction SetRadioChecked: PControl;
SetRadioCheckedOldfunction SetRadioCheckedOld: PControl;
Clickprocedure Click;
Checkedproperty Checked: Boolean;

function NewEditbox( AParent: PControl; Options: TEditOptions ): PControl;
Creates edit box control. To create multiline edit box, similar to TMemo in VCL, apply eoMultiline in Options. Following properties, methods, events are special for edit controls:
OnChangeproperty OnChange: TOnEvent;
SelectAllprocedure SelectAll;
ReplaceSelectionprocedure ReplaceSelection( const Value: KOLString; aCanUndo: Boolean );
DeleteLinesprocedure DeleteLines( FromLine, ToLine: Integer );
Item2Posfunction Item2Pos( ItemIdx: Integer ): DWORD;
Pos2Itemfunction Pos2Item( Pos: Integer ): DWORD;
SavePositionfunction SavePosition: TEditPositions;
RestorePositionprocedure RestorePosition( const p: TEditPositions );
UpdatePositionprocedure UpdatePosition( var p: TEditPositions; FromPos, CountInsertDelChars, CountInsertDelLines: Integer );
EditTabCharfunction EditTabChar: PControl;
CanUndofunction CanUndo: Boolean;
EmptyUndoBufferprocedure EmptyUndoBuffer;
Undofunction Undo: Boolean;
Textproperty Text: KOLString;
SelStartproperty SelStart: Integer;
SelLengthproperty SelLength: Integer;
Selectionproperty Selection: KOLString;
Countproperty Count: Integer;
Itemsproperty Items[ Idx: Integer ]: KOLString;
ItemSelectedproperty ItemSelected[ ItemIdx: Integer ]: Boolean;
TextAlignproperty TextAlign: TTextAlign;
Ed_Transparentproperty Ed_Transparent: Boolean;

function NewRichEdit( AParent: PControl; Options: TEditOptions ): PControl;
Creates rich text edit control. A rich edit control is a window in which the user can enter and edit text. The text can be assigned character and paragraph formatting, and can include embedded OLE objects. Rich edit controls provide a programming interface for formatting text. However, an application must implement any user interface components necessary to make formatting operations available to the user.
    Note: eoPassword, eoMultiline options have no effect for RichEdit control. Some operations are supersided with special versions of those, created especially for RichEdit, but in some cases it is necessary to use another properties and methods, specially designed for RichEdit (see methods and properties, which names are starting from RE_...).
    Following properties, methods, events are special for edit controls:
OnSelChangeproperty OnSelChange: TOnEvent;
OnRE_InsOvrMode_Changeproperty OnRE_InsOvrMode_Change: TOnEvent;
OnProgressproperty OnProgress: TOnEvent;
OnRE_OverURLproperty OnRE_OverURL: TOnEvent;
OnRE_URLClickproperty OnRE_URLClick: TOnEvent;
BeginUpdateprocedure BeginUpdate;
SelectAllprocedure SelectAll;
ReplaceSelectionprocedure ReplaceSelection( const Value: KOLString; aCanUndo: Boolean );
DeleteLinesprocedure DeleteLines( FromLine, ToLine: Integer );
RE_TextSizePrecisefunction RE_TextSizePrecise: Integer;
RE_FmtStandardfunction RE_FmtStandard: PControl;
RE_LoadFromStreamfunction RE_LoadFromStream( Stream: PStream; Length: Integer; Format: TRETextFormat; SelectionOnly: Boolean ): Boolean;
RE_SaveToStreamfunction RE_SaveToStream( Stream: PStream; Format: TRETextFormat; SelectionOnly: Boolean ): Boolean;
RE_LoadFromFilefunction RE_LoadFromFile( const Filename: KOLString; Format: TRETextFormat; SelectionOnly: Boolean ): Boolean;
RE_SaveToFilefunction RE_SaveToFile( const Filename: KOLString; Format: TRETextFormat; SelectionOnly: Boolean ): Boolean;
RE_HideSelectionprocedure RE_HideSelection( aHide: Boolean );
RE_SearchTextfunction RE_SearchText( const Value: KOLString; MatchCase, WholeWord, ScanForward: Boolean; SearchFrom, SearchTo: Integer ): Integer;
RE_WSearchTextfunction RE_WSearchText( const Value: WideString; MatchCase, WholeWord, ScanForward: Boolean; SearchFrom, SearchTo: Integer ): Integer;
RE_NoOLEDragDropfunction RE_NoOLEDragDrop: PControl;
CanUndofunction CanUndo: Boolean;
EmptyUndoBufferprocedure EmptyUndoBuffer;
Undofunction Undo: Boolean;
RE_Redofunction RE_Redo: Boolean;
SelStartproperty SelStart: Integer;
SelLengthproperty SelLength: Integer;
Selectionproperty Selection: KOLString;
Countproperty Count: Integer;
Itemsproperty Items[ Idx: Integer ]: KOLString;
MaxTextSizeproperty MaxTextSize: DWORD;
TextSizeproperty TextSize: Integer;
RE_TextSizeproperty RE_TextSize[ Units: TRichTextSize ]: Integer;
RE_CharFmtAreaproperty RE_CharFmtArea: TRichFmtArea;
RE_CharFormatproperty RE_CharFormat: TCharFormat;
RE_Fontproperty RE_Font: PGraphicTool;
RE_FmtBoldproperty RE_FmtBold: Boolean;
RE_FmtItalicproperty RE_FmtItalic: Boolean;
RE_FmtStrikeoutproperty RE_FmtStrikeout: Boolean;
RE_FmtUnderlineproperty RE_FmtUnderline: Boolean;
RE_FmtUnderlineStyleproperty RE_FmtUnderlineStyle: TRichUnderline;
RE_FmtProtectedproperty RE_FmtProtected: Boolean;
RE_FmtProtectedValidproperty RE_FmtProtectedValid: Boolean;
RE_FmtHiddenproperty RE_FmtHidden: Boolean;
RE_FmtHiddenValidproperty RE_FmtHiddenValid: Boolean;
RE_FmtLinkproperty RE_FmtLink: Boolean;
RE_FmtFontSizeproperty RE_FmtFontSize: Integer index( 12 shl 16 ) or CFM_SIZE;
RE_FmtFontSizeValidproperty RE_FmtFontSizeValid: Boolean;
RE_FmtAutoBackColorproperty RE_FmtAutoBackColor: Boolean;
RE_FmtFontColorproperty RE_FmtFontColor: Integer index( 20 shl 16 ) or CFM_COLOR;
RE_FmtFontColorValidproperty RE_FmtFontColorValid: Boolean;
RE_FmtAutoColorproperty RE_FmtAutoColor: Boolean;
RE_FmtBackColorproperty RE_FmtBackColor: Integer index(( 64 + 32 ) shl 16 ) or CFM_BACKCOLOR;
RE_FmtFontOffsetproperty RE_FmtFontOffset: Integer index( 16 shl 16 ) or CFM_OFFSET;
RE_FmtFontOffsetValidproperty RE_FmtFontOffsetValid: Boolean;
RE_FmtFontCharsetproperty RE_FmtFontCharset: Integer index( 25 shl 16 ) or CFM_CHARSET;
RE_FmtFontCharsetValidproperty RE_FmtFontCharsetValid: Boolean;
RE_FmtFontNameproperty RE_FmtFontName: KOLString;
RE_FmtFontNameValidproperty RE_FmtFontNameValid: Boolean;
RE_ParaFmtproperty RE_ParaFmt: TParaFormat;
RE_TextAlignproperty RE_TextAlign: TRichTextAlign;
RE_TextAlignValidproperty RE_TextAlignValid: Boolean;
RE_Numberingproperty RE_Numbering: Boolean;
RE_NumStyleproperty RE_NumStyle: TRichNumbering;
RE_NumStartproperty RE_NumStart: Integer;
RE_NumBracketsproperty RE_NumBrackets: TRichNumBrackets;
RE_NumTabproperty RE_NumTab: Integer;
RE_NumberingValidproperty RE_NumberingValid: Boolean;
RE_Levelproperty RE_Level: Integer;
RE_SpaceBeforeproperty RE_SpaceBefore: Integer;
RE_SpaceBeforeValidproperty RE_SpaceBeforeValid: Boolean;
RE_SpaceAfterproperty RE_SpaceAfter: Integer;
RE_SpaceAfterValidproperty RE_SpaceAfterValid: Boolean;
RE_LineSpacingproperty RE_LineSpacing: Integer;
RE_SpacingRuleproperty RE_SpacingRule: Integer;
RE_LineSpacingValidproperty RE_LineSpacingValid: Boolean;
RE_Indentproperty RE_Indent: Integer index( 20 shl 16 ) or PFM_OFFSET;
RE_IndentValidproperty RE_IndentValid: Boolean;
RE_StartIndentproperty RE_StartIndent: Integer index( 12 shl 16 ) or PFM_STARTINDENT;
RE_StartIndentValidproperty RE_StartIndentValid: Boolean;
RE_RightIndentproperty RE_RightIndent: Integer index( 16 shl 16 ) or PFM_RIGHTINDENT;
RE_RightIndentValidproperty RE_RightIndentValid: Boolean;
RE_TabCountproperty RE_TabCount: Integer;
RE_Tabsproperty RE_Tabs[ Idx: Integer ]: Integer;
RE_TabsValidproperty RE_TabsValid: Boolean;
RE_AutoKeyboardproperty RE_AutoKeyboard: Boolean;
RE_AutoFontproperty RE_AutoFont: Boolean;
RE_AutoFontSizeAdjustproperty RE_AutoFontSizeAdjust: Boolean;
RE_DualFontproperty RE_DualFont: Boolean;
RE_UIFontsproperty RE_UIFonts: Boolean;
RE_IMECancelCompleteproperty RE_IMECancelComplete: Boolean;
RE_IMEAlwaysSendNotifyproperty RE_IMEAlwaysSendNotify: Boolean;
RE_OverwriteModeproperty RE_OverwriteMode: Boolean;
RE_DisableOverwriteChangeproperty RE_DisableOverwriteChange: Boolean;
RE_Textproperty RE_Text[ Format: TRETextFormat; SelectionOnly: Boolean ]: KOLString;
RE_Errorproperty RE_Error: Integer;
RE_AutoURLDetectproperty RE_AutoURLDetect: Boolean;
RE_URLproperty RE_URL: KOLString;
RE_Transparentproperty RE_Transparent: Boolean;
RE_Zoomproperty RE_Zoom: TSmallPoint;

function NewRichEdit1( AParent: PControl; Options: TEditOptions ): PControl;
Like NewRichEdit, but to work with older RichEdit control version 1.0 (window class 'RichEdit' forced to use instead of 'RichEdit20A', even if library RICHED20.DLL found and loaded successfully). One more difference - OleInit is not called, so the most of OLE capabilities of RichEdit could not working.

function NewListbox( AParent: PControl; Options: TListOptions ): PControl;
Creates list box control. Following properties, methods and events are special for Listbox:
OnMeasureItemproperty OnMeasureItem: TOnMeasureItem;
OnChangeproperty OnChange: TOnEvent;
OnSelChangeproperty OnSelChange: TOnEvent;
OnDrawItemproperty OnDrawItem: TOnDrawItem;
BeginUpdateprocedure BeginUpdate;
IndexOffunction IndexOf( const S: KOLString ): Integer;
SearchForfunction SearchFor( const S: KOLString; StartAfter: Integer; Partial: Boolean ): Integer;
AddDirListprocedure AddDirList( const Filemask: KOLString; Attrs: DWORD );
Addfunction Add( const S: KOLString ): Integer;
Insertfunction Insert( Idx: Integer; const S: KOLString ): Integer;
Deleteprocedure Delete( Idx: Integer );
LBItemAtPosfunction LBItemAtPos( X, Y: Integer ): Integer;
SelLengthproperty SelLength: Integer;
CurIndexproperty CurIndex: Integer;
Countproperty Count: Integer;
Itemsproperty Items[ Idx: Integer ]: KOLString;
ItemSelectedproperty ItemSelected[ ItemIdx: Integer ]: Boolean;
ItemDataproperty ItemData[ Idx: Integer ]: DWORD;
LVItemHeightproperty LVItemHeight: Integer;
LBTopIndexproperty LBTopIndex: Integer;

function NewCombobox( AParent: PControl; Options: TComboOptions ): PControl;
Creates new combo box control. Note, that it is not possible to align combobox caLeft or caRight: this can cause infinite recursion in the application.
Following properties, methods and events are special for Combobox:
OnDropDownproperty OnDropDown: TOnEvent;
OnCloseUpproperty OnCloseUp: TOnEvent;
OnMeasureItemproperty OnMeasureItem: TOnMeasureItem;
OnChangeproperty OnChange: TOnEvent;
OnSelChangeproperty OnSelChange: TOnEvent;
OnDrawItemproperty OnDrawItem: TOnDrawItem;
AddDirListprocedure AddDirList( const Filemask: KOLString; Attrs: DWORD );
Addfunction Add( const S: KOLString ): Integer;
Insertfunction Insert( Idx: Integer; const S: KOLString ): Integer;
Deleteprocedure Delete( Idx: Integer );
CurIndexproperty CurIndex: Integer;
Countproperty Count: Integer;
Itemsproperty Items[ Idx: Integer ]: KOLString;
ItemSelectedproperty ItemSelected[ ItemIdx: Integer ]: Boolean;
ItemDataproperty ItemData[ Idx: Integer ]: DWORD;
DroppedWidthproperty DroppedWidth: Integer;
DroppedDownproperty DroppedDown: Boolean;

function NewProgressbar( AParent: PControl ): PControl;
Creates progress bar control. Following properties are special for progress bar:
Progressproperty Progress: Integer index(( PBM_SETPOS or $8000 ) shl 16 ) or PBM_GETPOS;
MaxProgressproperty MaxProgress: Integer index(( PBM_SETRANGE32 or $8000 ) shl 16 ) or PBM_GETRANGE;
ProgressColorproperty ProgressColor: TColor;
ProgressBkColorproperty ProgressBkColor: TColor;

function NewProgressbarEx( AParent: PControl; Options: TProgressbarOptions ): PControl;
Can create progress bar with smooth style (progress is not segmented onto bricks) or/and vertical progress bar - using additional parameter. For list of properties, suitable for progress bars, see NewProgressbar.

function NewListView( AParent: PControl; Style: TListViewStyle; Options: TListViewOptions; ImageListSmall, ImageListNormal, ImageListState: PImageList ): PControl;
Creates list view control. It is very powerful control, which can partially compensate absence of grid controls (in lvsDetail view mode). Properties, methods and events, special for list view control are:
OnMeasureItemproperty OnMeasureItem: TOnMeasureItem;
OnEndEditLVItemproperty OnEndEditLVItem: TOnEditLVItem;
OnLVDeleteproperty OnLVDelete: TOnDeleteLVItem;
OnDeleteLVItemproperty OnDeleteLVItem: TOnDeleteLVItem;
OnDeleteAllLVItemsproperty OnDeleteAllLVItems: TOnEvent;
OnLVDataproperty OnLVData: TOnLVData;
OnCompareLVItemsproperty OnCompareLVItems: TOnCompareLVItems;
OnColumnClickproperty OnColumnClick: TOnLVColumnClick;
OnLVStateChangeproperty OnLVStateChange: TOnLVStateChange;
OnDrawItemproperty OnDrawItem: TOnDrawItem;
OnLVCustomDrawproperty OnLVCustomDraw: TOnLVCustomDraw;
BeginUpdateprocedure BeginUpdate;
SetUnicodefunction SetUnicode( Unicode: Boolean ): PControl;
LVColAddprocedure LVColAdd( const aText: KOLString; aalign: TTextAlign; aWidth: Integer );
LVColInsertprocedure LVColInsert( ColIdx: Integer; const aText: KOLString; aAlign: TTextAlign; aWidth: Integer );
LVColDeleteprocedure LVColDelete( ColIdx: Integer );
LVNextItemfunction LVNextItem( IdxPrev: Integer; Attrs: DWORD ): Integer;
LVNextSelectedfunction LVNextSelected( IdxPrev: Integer ): Integer;
LVAddfunction LVAdd( const aText: KOLString; ImgIdx: Integer; State: TListViewItemState; StateImgIdx, OverlayImgIdx: Integer; Data: DWORD ): Integer;
LVItemAddfunction LVItemAdd( const aText: KOLString ): Integer;
LVInsertfunction LVInsert( Idx: Integer; const aText: KOLString; ImgIdx: Integer; State: TListViewItemState; StateImgIdx, OverlayImgIdx: Integer; Data: DWORD ): Integer;
LVItemInsertfunction LVItemInsert( Idx: Integer; const aText: KOLString ): Integer;
LVDeleteprocedure LVDelete( Idx: Integer );
LVSetItemprocedure LVSetItem( Idx, Col: Integer; const aText: KOLString; ImgIdx: Integer; State: TListViewItemState; StateImgIdx, OverlayImgIdx: Integer; Data: DWORD );
LVSelectAllprocedure LVSelectAll;
LVItemRectfunction LVItemRect( Idx: Integer; Part: TGetLVItemPart ): TRect;
LVSubItemRectfunction LVSubItemRect( Idx, ColIdx: Integer ): TRect;
LVItemAtPosfunction LVItemAtPos( X, Y: Integer ): Integer;
LVItemAtPosExfunction LVItemAtPosEx( X, Y: Integer; var Where: TWherePosLVItem ): Integer;
LVMakeVisibleprocedure LVMakeVisible( Item: Integer; PartiallyOK: Boolean );
LVEditItemLabelprocedure LVEditItemLabel( Idx: Integer );
LVSortprocedure LVSort;
LVSortDataprocedure LVSortData;
LVSortColumnprocedure LVSortColumn( Idx: Integer );
SelLengthproperty SelLength: Integer;
Countproperty Count: Integer;
ItemSelectedproperty ItemSelected[ ItemIdx: Integer ]: Boolean;
RightClickproperty RightClick: Boolean;
ImageListSmallproperty ImageListSmall: PImageList;
ImageListNormalproperty ImageListNormal: PImageList;
ImageListStateproperty ImageListState: PImageList;
LVStyleproperty LVStyle: TListViewStyle;
LVOptionsproperty LVOptions: TListViewOptions;
LVTextColorproperty LVTextColor: TColor;
LVTextBkColorproperty LVTextBkColor: TColor;
LVBkColorproperty LVBkColor: TColor;
LVColCountproperty LVColCount: Integer;
LVColWidthproperty LVColWidth[ Item: Integer ]: Integer;
LVColTextproperty LVColText[ Idx: Integer ]: KOLString;
LVColAlignproperty LVColAlign[ Idx: Integer ]: TTextAlign;
LVColImageproperty LVColImage[ Idx: Integer ]: Integer;
LVColOrderproperty LVColOrder[ Idx: Integer ]: Integer;
LVCountproperty LVCount: Integer;
LVCurItemproperty LVCurItem: Integer;
LVFocusItemproperty LVFocusItem: Integer;
LVItemStateproperty LVItemState[ Idx: Integer ]: TListViewItemState;
LVItemStateImgIdxproperty LVItemStateImgIdx[ Idx: Integer ]: Integer;
LVItemOverlayImgIdxproperty LVItemOverlayImgIdx[ Idx: Integer ]: Integer;
LVItemDataproperty LVItemData[ Idx: Integer ]: DWORD;
LVSelCountproperty LVSelCount: Integer;
LVItemImageIndexproperty LVItemImageIndex[ Idx: Integer ]: Integer;
LVItemsproperty LVItems[ Idx, Col: Integer ]: KOLString;
LVItemPosproperty LVItemPos[ Idx: Integer ]: TPoint;
LVTopItemproperty LVTopItem: Integer;
LVPerPageproperty LVPerPage: Integer;
LVItemHeightproperty LVItemHeight: Integer;

function NewTreeView( AParent: PControl; Options: TTreeViewOptions; ImgListNormal, ImgListState: PImageList ): PControl;
Creates tree view control. See tree view methods and properties:
OnSelChangeproperty OnSelChange: TOnEvent;
OnTVBeginDragproperty OnTVBeginDrag: TOnTVBeginDrag;
OnTVBeginEditproperty OnTVBeginEdit: TOnTVBeginEdit;
OnTVEndEditproperty OnTVEndEdit: TOnTVEndEdit;
OnTVExpandingproperty OnTVExpanding: TOnTVExpanding;
OnTVExpandedproperty OnTVExpanded: TOnTVExpanded;
OnTVDeleteproperty OnTVDelete: TOnTVDelete;
OnTVSelChangingproperty OnTVSelChanging: TOnTVSelChanging;
BeginUpdateprocedure BeginUpdate;
SetUnicodefunction SetUnicode( Unicode: Boolean ): PControl;
TVInsertfunction TVInsert( nParent, nAfter: THandle; const Txt: KOLString ): THandle;
TVDeleteprocedure TVDelete( Item: THandle );
TVItemPathfunction TVItemPath( Item: THandle; Delimiter: KOLChar ): KOLString;
TVItemAtPosfunction TVItemAtPos( x, y: Integer; var Where: DWORD ): THandle;
TVExpandprocedure TVExpand( Item: THandle; Flags: DWORD );
TVSortprocedure TVSort( N: THandle );
TVEditItemprocedure TVEditItem( Item: THandle );
TVStopEditprocedure TVStopEdit( Cancel: Boolean );
Countproperty Count: Integer;
ImageListNormalproperty ImageListNormal: PImageList;
ImageListStateproperty ImageListState: PImageList;
TVSelectedproperty TVSelected: THandle;
TVDropHilightedproperty TVDropHilighted: THandle;
TVFirstVisibleproperty TVFirstVisible: THandle;
TVIndentproperty TVIndent: Integer;
TVVisibleCountproperty TVVisibleCount: Integer;
TVRootproperty TVRoot: THandle;
TVItemChildproperty TVItemChild[ Item: THandle ]: THandle;
TVItemHasChildrenproperty TVItemHasChildren[ Item: THandle ]: Boolean;
TVItemChildCountproperty TVItemChildCount[ Item: THandle ]: Integer;
TVItemNextproperty TVItemNext[ Item: THandle ]: THandle;
TVItemPreviousproperty TVItemPrevious[ Item: THandle ]: THandle;
TVItemNextVisibleproperty TVItemNextVisible[ Item: THandle ]: THandle;
TVItemPreviousVisibleproperty TVItemPreviousVisible[ Item: THandle ]: THandle;
TVItemParentproperty TVItemParent[ Item: THandle ]: THandle;
TVItemTextproperty TVItemText[ Item: THandle ]: KOLString;
TVItemRectproperty TVItemRect[ Item: THandle; TextOnly: Boolean ]: TRect;
TVItemVisibleproperty TVItemVisible[ Item: THandle ]: Boolean;
TVRightClickSelectproperty TVRightClickSelect: Boolean;
TVEditingproperty TVEditing: Boolean;
TVItemBoldproperty TVItemBold[ Item: THandle ]: Boolean;
TVItemCutproperty TVItemCut[ Item: THandle ]: Boolean;
TVItemDropHighlightedproperty TVItemDropHighlighted[ Item: THandle ]: Boolean;
TVItemExpandedproperty TVItemExpanded[ Item: THandle ]: Boolean;
TVItemExpandedOnceproperty TVItemExpandedOnce[ Item: THandle ]: Boolean;
TVItemSelectedproperty TVItemSelected[ Item: THandle ]: Boolean;
TVItemImageproperty TVItemImage[ Item: THandle ]: Integer;
TVItemSelImgproperty TVItemSelImg[ Item: THandle ]: Integer;
TVItemOverlayproperty TVItemOverlay[ Item: THandle ]: Integer;
TVItemStateImgproperty TVItemStateImg[ Item: THandle ]: Integer;
TVItemDataproperty TVItemData[ Item: THandle ]: Pointer;

function NewTabControl( AParent: PControl; const Tabs: array of PKOLChar; Options: TTabControlOptions; ImgList: PImageList; ImgList1stIdx: Integer ): PControl;
Creates new tab control (like notebook). To place child control on a certain page of TabControl, use property Pages[ Idx ], for example:

 Label1 := NewLabel( TabControl1.Pages[ 0 ], 'Label1' );

    To determine number of pages at run time, use property Count ;
to determine which page is currently selected (or to change selection), use property CurIndex ;
to feedback to switch between tabs assign your handler to OnSelChange event;
Note, that by default, tab control is created with a border lowered to tab control's parent. To remove it, you can apply WS_EX_TRANSPARENT extended style (see TControl.ExStyle property), but painting of some child controls can be strange a bit in this case (no border drawing for edit controls was found, but not always...). You can also apply style WS_THICKFRAME (TControl.Style property) to make the border raised.
Other methods and properties, suitable for tab control, are:
OnChangeproperty OnChange: TOnEvent;
IndexOffunction IndexOf( const S: KOLString ): Integer;
SearchForfunction SearchFor( const S: KOLString; StartAfter: Integer; Partial: Boolean ): Integer;
SetUnicodefunction SetUnicode( Unicode: Boolean ): PControl;
TC_Insertfunction TC_Insert( Idx: Integer; const TabText: KOLString; TabImgIdx: Integer ): PControl;
TC_Deleteprocedure TC_Delete( Idx: Integer );
TC_InsertControlprocedure TC_InsertControl( Idx: Integer; const TabText: KOLString; TabImgIdx: Integer; Page: PControl );
TC_Removefunction TC_Remove( Idx: Integer ): PControl;
TC_SetPaddingprocedure TC_SetPadding( cx, cy: Integer );
TC_TabAtPosfunction TC_TabAtPos( x, y: Integer ): Integer;
TC_DisplayRectfunction TC_DisplayRect: TRect;
TC_IndexOffunction TC_IndexOf( const S: KOLString ): Integer;
TC_SearchForfunction TC_SearchFor( const S: KOLString; StartAfter: Integer; Partial: Boolean ): Integer;
ImageListNormalproperty ImageListNormal: PImageList;
Pagesproperty Pages[ Idx: Integer ]: PControl;
TC_Pagesproperty TC_Pages[ Idx: Integer ]: PControl;
TC_Itemsproperty TC_Items[ Idx: Integer ]: KOLString;
TC_Imagesproperty TC_Images[ Idx: Integer ]: Integer;
TC_ItemRectproperty TC_ItemRect[ Idx: Integer ]: TRect;

function NewTabEmpty( AParent: PControl; Options: TTabControlOptions; ImgList: PImageList ): PControl;
Creates new empty tab control for using metods TC_Insert (to create Pages as Panel), or TC_InsertControl (if you want using your custom Pages).

function NewToolbar( AParent: PControl; Align: TControlAlign; Options: TToolbarOptions; Bitmap: HBitmap; const Buttons: array of PKOLChar; const BtnImgIdxArray: array of Integer ): PControl;
Creates toolbar control. Bitmap (if present) must contain images for all buttons excluding separators (defined by string '-' in Buttons array) and system images, otherwise last buttons will no have images at all. Image width for every button is assumed to be equal to Bitmap height (if last of "squares" has insufficient width, it will not be used). To define fixed buttons, use characters '+' or '-' as a prefix for button string (even empty). To create groups of (radio-)buttons, use also '!' follow '+' or '-'. (These rules are similar used in menu creation). To define drop down button, use (as first) prefix '^'. (Do not forget to set OnTBDropDown event for this case). If You want to assign images to buttons not in the same order how these are placed in Bitmap (or You use system bitmap), define for every button (in BtnImgIdxArray array) indexes for every button (excluding separator buttons). Otherwise, it is possible to define index only for first button (e.g., [0]). It is also possible to change TBImages[ ] property for such purpose, or do the same in method TBSetBtnImgIdx).
Following properties, methods and event are specially designed to work with toolbar control:
OnDropDownproperty OnDropDown: TOnEvent;
OnClickproperty OnClick: TOnEvent;
OnTBDropDownproperty OnTBDropDown: TOnEvent;
OnTBClickproperty OnTBClick: TOnEvent;
OnTBCustomDrawproperty OnTBCustomDraw: TOnTBCustomDraw;
TBAddBitmapprocedure TBAddBitmap( Bitmap: HBitmap );
TBAddButtonsfunction TBAddButtons( const Buttons: array of PKOLChar; const BtnImgIdxArray: array of Integer ): Integer;
TBInsertButtonsfunction TBInsertButtons( BeforeIdx: Integer; Buttons: array of PKOLChar; BtnImgIdxArray: array of Integer ): Integer;
TBDeleteButtonprocedure TBDeleteButton( BtnID: Integer );
TBDeleteBtnByIdxprocedure TBDeleteBtnByIdx( Idx: Integer );
TBClearprocedure TBClear;
TBAssignEventsprocedure TBAssignEvents( BtnID: Integer; Events: array of TOnToolbarButtonClick );
TBResetImgIdxprocedure TBResetImgIdx( BtnID, BtnCount: Integer );
TBItem2Indexfunction TBItem2Index( BtnID: Integer ): Integer;
TBIndex2Itemfunction TBIndex2Item( Idx: Integer ): Integer;
TBConvertIdxArray2IDprocedure TBConvertIdxArray2ID( const IdxVars: array of PDWORD );
TBButtonSeparatorfunction TBButtonSeparator( BtnID: Integer ): Boolean;
TBButtonAtPosfunction TBButtonAtPos( X, Y: Integer ): Integer;
TBBtnIdxAtPosfunction TBBtnIdxAtPos( X, Y: Integer ): Integer;
TBMoveBtnfunction TBMoveBtn( FromIdx, ToIdx: Integer ): Boolean;
TBSetTooltipsprocedure TBSetTooltips( BtnID1st: Integer; const Tooltips: array of PKOLChar );
CurIndexproperty CurIndex: Integer;
Countproperty Count: Integer;
RightClickproperty RightClick: Boolean;
CurItemproperty CurItem: Integer;
TBButtonCountproperty TBButtonCount: Integer;
TBBtnImgWidthproperty TBBtnImgWidth: Integer;
TBButtonEnabledproperty TBButtonEnabled[ BtnID: Integer ]: Boolean;
TBButtonVisibleproperty TBButtonVisible[ BtnID: Integer ]: Boolean;
TBButtonCheckedproperty TBButtonChecked[ BtnID: Integer ]: Boolean;
TBButtonMarkedproperty TBButtonMarked[ BtnID: Integer ]: Boolean;
TBButtonPressedproperty TBButtonPressed[ BtnID: Integer ]: Boolean;
TBButtonTextproperty TBButtonText[ BtnID: Integer ]: KOLString;
TBButtonImageproperty TBButtonImage[ BtnID: Integer ]: Integer;
TBButtonRectproperty TBButtonRect[ BtnID: Integer ]: TRect;
TBButtonWidthproperty TBButtonWidth[ BtnID: Integer ]: Integer;
TBButtonLParamproperty TBButtonLParam[ const Idx: Integer ]: DWORD;
TBButtonsMinWidthproperty TBButtonsMinWidth: Integer;
TBButtonsMaxWidthproperty TBButtonsMaxWidth: Integer;
TBRowsproperty TBRows: Integer;

function NewDateTimePicker( AParent: PControl; Options: TDateTimePickerOptions ): PControl;
Creates date and time picker common control.

function NewImageList( AOwner: PControl ): PImageList;
Constructor of TImageList object. Unlike other non-visual objects, image list can be parented by TControl object (but this does not *must*), and in that case it is destroyed automatically when its parent control is destroyed. Every control can have several TImageList objects, linked to a simple list. But if any TImageList object is destroyed, all following ones are destroyed too (at least, now I implemented it so).

function NewTimer( Interval: Integer ): PTimer;
Constructs initially disabled timer with interval 1000 (1 second).

function NewMMTimer( Interval: Integer ): PMMTimer;
Creates multimedia timer object. Initially, it has Resolution = 0, Periodic = TRUE and Enabled = FALSE. Do not forget also to assign your event handler to OnTimer to do something on timer shot.

type TOnTrayIconMouse = procedure( Sender: PObj; Message: Word ) of object;
Event type to be called when Applet receives a message from an icon, added to the taskbar tray.

function NewTrayIcon( Wnd: PControl; Icon: HIcon ): PTrayIcon;
Constructor of TTrayIcon object. Pass main form or applet as Wnd parameter.

type TOnAnotherInstance = procedure( const CmdLine: KOLString ) of object;
Event type to use in JustOneNotify function.

function JustOne( Wnd: PControl; const Identifier: AnsiString ): Boolean;
Returns True, if this is a first instance. For all other instances (application is already running), False is returned.

function JustOneNotify( Wnd: PControl; const Identifier: KOLString; const aOnAnotherInstance: TOnAnotherInstance ): Boolean;
Returns True, if this is a first instance. For all other instances (application is already running), False is returned. If handler aOnAnotherInstance passed, it is called (in first instance) every time when another instance of an application is started, receiving command line used to run it.

function MsgBox( const S: KOLString; Flags: DWORD ): DWORD;
Displays message box with the same title as Applet.Caption. If applet is not running, and Applet global variable is not assigned, caption 'Error' is displayed (but actually this is not an error - the system does so, if nil is passed as a title).
    Returns ID_... result (correspondently to flags passed (MB_OK, MBYESNO, etc. -> ID_OK, ID_YES, ID_NO, etc.)

procedure MsgOK( const S: KOLString );
Displays message box with the same title as Applet.Caption (or 'Error', if Applet is not running).

function ShowMsg( const S: KOLString; Flags: DWORD ): DWORD;
Displays message box like MsgBox, but uses Applet.Handle as a parent (so the message has no button on a task bar).

procedure ShowMessage( const S: KOLString );
Like ShowMsg, but has only styles MB_OK and MB_SETFOREGROUND.

procedure SpeakerBeep( Freq: Word; Duration: DWORD );
On Windows NT, calls Windows.Beep. On Windows 9x, produces beep on speaker of desired frequency during given duration time (in milliseconds).

function SysErrorMessage( ErrorCode: Integer ): KOLString;
Creates and returns a string containing formatted system error message. It is possible then to display this message or write it to a log file, e.g.:

  ShowMsg( SysErrorMessage( GetLastError ) );

64-bit integer numbers

type I64 = record
64 bit integer record. Use it and correspondent functions below in KOL projects to avoid dependancy from Delphi version (earlier versions of Delphi had no Int64 type).
  Lo, Hi: DWORD;
end;

type PI64 = ^ I64;

function MakeInt64( Lo, Hi: DWORD ): I64;

function Int2Int64( X: Integer ): I64;

procedure IncInt64( var I64: I64; Delta: Integer );
I64 := I64 + Delta;

procedure DecInt64( var I64: I64; Delta: Integer );
I64 := I64 - Delta;

function Add64( const X, Y: I64 ): I64;
Result := X + Y;

function Sub64( const X, Y: I64 ): I64;
Result := X - Y;

function Neg64( const X: I64 ): I64;
Result := -X;

function Mul64i( const X: I64; Mul: Integer ): I64;
Result := X * Mul;

function Div64i( const X: I64; D: Integer ): I64;
Result := X div D;

function Mod64i( const X: I64; D: Integer ): Integer;
Result := X mod D;

function Sgn64( const X: I64 ): Integer;
Result := sign( X ); i.e.:
if X < 0 then -1
if X = 0 then 0
if X > 0 then 1

function Cmp64( const X, Y: I64 ): Integer;
Result := sign( X - Y ); i.e.
if X < Y then -1
if X = Y then 0
if X > Y then 1

function Int64_2Str( X: I64 ): AnsiString;

function Int64_2Hex( X: I64; MinDigits: Integer ): AnsiString;

function Str2Int64( const S: AnsiString ): I64;

function Int64_2Double( const X: I64 ): Double;

function Double2Int64( D: Double ): I64;

Floating point numbers

function IsNan( const AValue: Double ): Boolean;
Checks if an argument passed is NAN.

function IsInfinity( const AValue: Double ): Boolean;
Checks if an argument passed is Infinite.

function IntPower( Base: Extended; Exponent: Integer ): Extended;
Result := Base ^ Exponent;

function NextPowerOf2( n: DWORD ): DWORD;
0->1, 1->1, 2->2, 3->4, 4->4, 5->8, ...

function Str2Double( const S: AnsiString ): Double;

function Str2Extended( const S: AnsiString ): Extended;

function Double2Str( D: Double ): AnsiString;

function Extended2Str( E: Extended ): AnsiString;

function Extended2StrDigits( D: Double; n: Integer ): AnsiString;
Converts floating point number to string, leaving exactly n digits following floating point.

function Double2StrEx( D: Double ): AnsiString;
experimental, do not use

function TruncD( D: Double ): Double;
Result := trunc( D ) as Double;


Small bit arrays (max 32 bits in array)

See also TBits object.

function GetBits( N: DWORD; first, last: Byte ): DWord;
Retuns bits straing from <first> and to <last> inclusively.

function GetBitsL( N: DWORD; from, len: Byte ): DWord;
Retuns len bits starting from index <from>.


Arithmetics, geometry and other utility functions

See also units KolMath.pas, CplxMath.pas and Err.pas.

function MulDiv( A, B, C: Integer ): Integer;
Returns A * B div C. Small and fast.

type TMethod = packed record
Is defined here because using of VCL classes.pas unit is not recommended in XCL. This record type is used often to set/access event handlers, referring to a procedure of object (usually to set such event to an ordinal procedure setting Data field to nil.
  Code: Pointer; Pointer to method code.
  If used to fake assigning to event handler of type 'procedure of object' with ordinal procedure pointer, use symbol '@' before method:
       Method.Code := @MyProcedure;
  Data: Pointer; Pointer to object, owning the method.
  To fake event of type 'procedure of object' with setting it to ordinal procedure assign here NIL;
When assigning TMethod record to event handler, typecast it with desired event type, e.g.:
       SomeObject.OnSomeEvent := TOnSomeEvent( Method );
end;

type PMethod = ^ TMethod;

function MakeMethod( Data, Code: Pointer ): TMethod;
Help function to construct TMethod record. Can be useful to assign regular type procedure/function as event handler for event, defined as object method (do not forget, that in that case it must have first dummy parameter to replace @Self, passed in EAX to methods of object).

function MakeRect( Left, Top, Right, Bottom: Integer ): TRect; stdcall;
Use it instead of VCL Rect function

function RectsEqual( const R1, R2: TRect ): Boolean;
Returns True if rectangles R1 and R2 have the same bounds

function RectsIntersected( const R1, R2: TRect ): Boolean;
Returns TRUE if rectangles R1 and R2 have at least one common point. Note, that right and bottom bounds of rectangles are not their part, so, if such points are lying on that bounds, FALSE is returned.

function PointInRect( const P: TPoint; const R: TRect ): Boolean;
Returns True if point P is located in rectangle R (including left and top bounds but without right and bottom bounds of the rectangle).

function OffsetPoint( const T: TPoint; dX, dY: Integer ): TPoint;

function OffsetSmallPoint( const T: TSmallPoint; dX, dY: SmallInt ): TSmallPoint;

function Point2SmallPoint( const T: TPoint ): TSmallPoint;

function SmallPoint2Point( const T: TSmallPoint ): TPoint;

function MakePoint( X, Y: Integer ): TPoint;
Use instead of VCL function Point

function MakeSmallPoint( X, Y: Integer ): TSmallPoint;
Use to construct TSmallPoint

function MakeFlags( FlgSet: PDWORD; FlgArray: array of Integer ): Integer;

function MakeDateTimeRange( D1, D2: TDateTime ): TDateTimeRange;
Returns TDateTimeRange from two TDateTime bounds.

procedure Swap( var X, Y: Integer );
exchanging values

function Min( X, Y: Integer ): Integer;
minimum of two integers

function Max( X, Y: Integer ): Integer;
maximum of two integers

function Abs( X: Integer ): Integer;
absolute value

function Sgn( X: Integer ): Integer;
sign of X: if X < 0, -1 is returned, if > 0, then +1, otherwise 0.

function iSqrt( X: Integer ): Integer;
square root

function iCbrt( X: DWORD ): Integer;
cubic root


String to number and number to string conversions

function Int2Hex( Value: DWord; Digits: Integer ): AnsiString;
Converts integer Value into string with hex number. Digits parameter determines minimal number of digits (will be completed by adding necessary number of leading zeroes).

function Int2Str( Value: Integer ): AnsiString;
Obvious.

procedure Int2PChar( s: PAnsiChar; Value: Integer );
Converts Value to string and puts it into buffer s. Buffer must have enough size to store the number converted: buffer overflow does not checked anyway!

function UInt2Str( Value: DWORD ): AnsiString;
The same as Int2Str, but for unsigned integer value.

function Int2StrEx( Value, MinWidth: Integer ): AnsiString;
Like Int2Str, but resulting string filled with leading spaces to provide at least MinWidth characters.

function Int2Rome( Value: Integer ): AnsiString;
Represents number 1..8999 to Rome numer.

function Int2Ths( I: Integer ): AnsiString;
Converts integer into string, separating every three digits from each other by character ThsSeparator. (Convert to thousands). You

function Int2Digs( Value, Digits: Integer ): AnsiString;
Converts integer to string, inserting necessary number of leading zeroes to provide desired length of string, given by Digits parameter. If resulting string is greater then Digits, string is not truncated anyway.

function Num2Bytes( Value: Double ): AnsiString;
Converts double float to string, considering it as a bytes count. If Value is sufficiently large, number is represented in kilobytes (with following letter K), or in megabytes (M), gigabytes (G) or terabytes (T). Resulting string number is truncated to two decimals (.XX) or to one (.X), if the second is 0.

function S2Int( S: PAnsiChar ): Integer;
Converts null-terminated string to Integer. Scanning stopped when any non-digit character found. Even empty string or string not containing valid integer number silently converted to 0.

function Str2Int( const Value: AnsiString ): Integer;
Converts string to integer. First character, which can not be recognized as a part of number, regards as a separator. Even empty string or string without number silently converted to 0.

function Hex2Int( const Value: AnsiString ): Integer;
Converts hexadecimal number to integer. Scanning is stopped when first non-hexadicimal character is found. Leading dollar ('$') character is skept (if present). Minus ('-') is not concerning as a sign of number and also stops scanning.

function cHex2Int( const Value: AnsiString ): Integer;
As Hex2Int, but also checks for leading '0x' and skips it.

function Octal2Int( const Value: AnsiString ): Integer;
Converts octal number to integer. Scanning is stopped on first non-octal digit (any char except 0..7). There are no checking if there octal numer in the parameter. If the first char is not octal digit, 0 is returned.

function Binary2Int( const Value: AnsiString ): Integer;
Converts binary number to integer. Like Octal2Int, but only digits 0 and 1 are allowed.

function ToRadix( number: Radix_int; radix, min_digits: Integer ): KOLString;
Converts unsigned number to string representing it literally in a numeric base given by radix parameter.

function FromRadixStr( var Rslt: Radix_int; s: PKOLChar; radix: Integer ): PKOLChar;
Converts unsigned number from string representation in a numeric base given by a radix parameter. Returns a pointer to a character next to the last digit of the number.

function FromRadix( const s: AnsiString; radix: Integer ): Radix_int;
Converts unsigned number from string representation in a numeric base given by a radix parameter. See also: FromRadixStr function.

function InsertSeparators( const s: KOLString; chars_between: Integer; Separator: KOLChar ): KOLString;
Inserts given Separator between symbols in s, separating each portion of chars_between characters with a Separator starting from right side. See also: Int2Ths function.

function Format( const fmt: KOLString; params: array of const ): KOLString;
Uses API call to wvsprintf, so does not understand extra formats, such as floating point, date/time, currency conversions. See list of available formats in win32.hlp (topic wsprintf).


Working with null-terminated and ansi strings

function StrComp( const Str1, Str2: PAnsiChar ): Integer;
Compares two strings fast. -1: Str1<Str2; 0: Str1=Str2; +1: Str1>Str2

function StrComp_NoCase( const Str1, Str2: PAnsiChar ): Integer;
Compares two strings fast without case sensitivity. Returns: -1 when Str1<Str2; 0 when Str1=Str2; +1 when Str1>Str2

function StrLComp_NoCase( const Str1, Str2: PAnsiChar; MaxLen: Cardinal ): Integer;
Compare two strings fast without case sensitivity. Terminating 0 is not considered, so if strings are equal, comparing is continued up to MaxLen bytes. Since this, pass minimum of lengths as MaxLen.

var StrComp_NoCase: function( const Str1, Str2: PAnsiChar ): Integer = StrComp_NoCase1;
Compares two strings fast without case sensitivity. Returns: -1 when Str1<Str2; 0 when Str1=Str2; +1 when Str1>Str2

function StrLComp( const Str1, Str2: PAnsiChar; MaxLen: Cardinal ): Integer;
Compare two strings (fast). Terminating 0 is not considered, so if strings are equal, comparing is continued up to MaxLen bytes. Since this, pass minimum of lengths as MaxLen.

function StrCopy( Dest, Source: PAnsiChar ): PAnsiChar;
Copy source string to destination (fast). Pointer to Dest is returned.

function StrCat( Dest, Source: PAnsiChar ): PAnsiChar;
Append source string to destination (fast). Pointer to Dest is returned.

function StrLen( const Str: PAnsiChar ): Cardinal;
StrLen returns the number of characters in Str, not counting the null terminator.

function StrScanLen( Str: PAnsiChar; Chr: AnsiChar; Len: Integer ): PAnsiChar;
Fast scans string Str of length Len searching character Chr. Pointer to a character next to found or to Str[Len] (if no one found) is returned.

function StrScan( Str: PAnsiChar; Chr: AnsiChar ): PAnsiChar;
Fast search of given character in a string. Pointer to found character (or nil) is returned.

function StrRScan( const Str: PAnsiChar; Chr: AnsiChar ): PAnsiChar;
StrRScan returns a pointer to the last occurrence of Chr in Str. If Chr does not occur in Str, StrRScan returns NIL. The null terminator is considered to be part of the string.

function StrIsStartingFrom( Str, Pattern: PKOLChar ): Boolean;
Returns True, if string Str is starting from Pattern, i.e. if Copy( Str, 1, StrLen( Pattern ) ) = Pattern. Str must not be nil!

function StrIsStartingFromNoCase( Str, Pattern: PAnsiChar ): Boolean;
Like StrIsStartingFrom above, but without case sensitivity.

function TrimLeft( const S: KOLString ): KOLString;
Removes spaces, tabulations and control characters from the starting of string S.

function TrimRight( const S: KOLString ): KOLString;
Removes spaces, tabulates and other control characters from the end of string S.

function Trim( const S: KOLString ): KOLString;
Makes TrimLeft and TrimRight for given string.

function RemoveSpaces( const S: KOLString ): KOLString;
Removes all characters less or equal to ' ' in S and returns it.

procedure Str2LowerCase( S: PAnsiChar );
Converts null-terminated string to lowercase (inplace).

function LowerCase( const S: Ansistring ): Ansistring;
Obvious.

function UpperCase( const S: Ansistring ): Ansistring;
Obvious.

function AnsiUpperCase( const S: Ansistring ): Ansistring;
Obvious.

function AnsiLowerCase( const S: Ansistring ): Ansistring;
Obvious.

function WAnsiUpperCase( const S: WideString ): WideString;
Obvious.

function WAnsiLowerCase( const S: WideString ): WideString;
Obvious.

function WStrComp( const S1, S2: WideString ): Integer;

function _WStrComp( S1, S2: PWideChar ): Integer;

function WStrScan( Str: PWideChar; Chr: WideChar ): PWideChar;
Fast search of given character in a string. Pointer to found character (or nil) is returned.

function WStrRScan( const Str: PWideChar; Chr: WideChar ): PWideChar;
StrRScan returns a pointer to the last occurrence of Chr in Str. If Chr does not occur in Str, StrRScan returns NIL. The null terminator is considered to be part of the string.

function AnsiCompareStr( const S1, S2: KOLString ): Integer;
AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare operation is controlled by the current Windows locale. The return value is the same as for CompareStr.

function _AnsiCompareStr( S1, S2: PKOLChar ): Integer;
The same, but for PChar ANSI strings

function AnsiCompareStrNoCase( const S1, S2: KOLString ): Integer;
AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare operation is controlled by the current Windows locale. The return value is the same as for CompareStr.

function _AnsiCompareStrNoCase( S1, S2: PKOLChar ): Integer;
The same, but for PChar ANSI strings

function AnsiCompareText( const S1, S2: KOLString ): Integer;

function AnsiEq( const S1, S2: KOLString ): Boolean;
Returns True, if AnsiLowerCase(S1) = AnsiLowerCase(S2). I.e., if ANSI stringsare equal to each other without caring of characters case sensitivity.

function AnsiCompareStrA( const S1, S2: AnsiString ): Integer;
AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare operation is controlled by the current Windows locale. The return value is the same as for CompareStr.

function _AnsiCompareStrA( S1, S2: PAnsiChar ): Integer;
The same, but for PChar ANSI strings

function AnsiCompareStrNoCaseA( const S1, S2: AnsiString ): Integer;
AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare operation is controlled by the current Windows locale. The return value is the same as for CompareStr.

function _AnsiCompareStrNoCaseA( S1, S2: PAnsiChar ): Integer;
The same, but for PChar ANSI strings

function AnsiCompareTextA( const S1, S2: AnsiString ): Integer;

function LStrFromPWCharLen( Source: PWideChar; Length: Integer ): AnsiString;
from Delphi5 - because D2 does not contain it.

function LStrFromPWChar( Source: PWideChar ): AnsiString;
from Delphi5 - because D2 does not contain it.

function CopyEnd( const S: KOLString; Idx: Integer ): KOLString;
Returns copy of source string S starting from Idx up to the end of string S. Works correctly for case, when Idx > Length( S ) (returns empty string for such case).

function CopyTail( const S: KOLString; Len: Integer ): KOLString;
Returns last Len characters of the source string. If Len > Length( S ), entire string S is returned.

procedure DeleteTail( var S: KOLString; Len: Integer );
Deletes last Len characters from string.

function IndexOfChar( const S: KOLString; Chr: KOLChar ): Integer;
Returns index of given character (1..Length(S)), or -1 if a character not found.

function IndexOfCharsMin( const S, Chars: KOLString ): Integer;
Returns index (in string S) of those character, what is taking place in Chars string and located nearest to start of S. If no such characters in string S found, -1 is returned.

function IndexOfWideCharsMin( const S, Chars: WideString ): Integer;
Returns index (in wide string S) of those wide character, what is taking place in Chars wide string and located nearest to start of S. If no such characters in string S found, -1 is returned.

function IndexOfStr( const S, Sub: KOLString ): Integer;
Returns index of given substring in source string S. If found, 1..Length(S)-Length(Sub), if not found, -1.

function Parse( var S: KOLString; const Separators: KOLString ): KOLString;
Returns first characters of string S, separated from others by one of characters, taking place in Separators string, assigning a tail of string (after found separator) to source string. If no separator characters found, source string S is returned, and source string itself becomes empty.

function WParse( var S: WideString; const Separators: WideString ): WideString;
Returns first wide characters of wide string S, separated from others by one of wide characters, taking place in Separators wide string, assigning a tail of wide string (following found separator) to the source one. If there are no separator characters found, source wide string S is returned, and source wide string itself becomes empty.

function ParsePascalString( var S: AnsiString; const Separators: AnsiString ): AnsiString;
Returns first characters of string S, separated from others by one of characters, taking place in Separators string, assigning a tail of string (after the found separator) to source string. If there are no separator characters found, the source string S is returned, and the source string itself becomes empty. Additionally: if the first (after a blank space) is the quote "'" or '#', pascal string is assumung first and is converted to usual string (without quotas) before analizing of other separators.

function String2PascalStrExpr( const S: AnsiString ): AnsiString;
Converts string to Pascal-like string expression (concatenation of strings with quotas and characters with leading '#').

function StrEq( const S1, S2: AnsiString ): Boolean;
Returns True, if LowerCase(S1) = LowerCase(S2). I.e., if strings are equal to each other without caring of characters case sensitivity (ASCII only).

function WAnsiEq( const S1, S2: WideString ): Boolean;
Returns True, if AnsiLowerCase(S1) = AnsiLowerCase(S2). I.e., if ANSI stringsare equal to each other without caring of characters case sensitivity.

function StrIn( const S: AnsiString; const A: array of String ): Boolean;
Returns True, if S is "equal" to one of strings, taking place in A array. To check equality, StrEq function is used, i.e. comaprison is taking place without case sensitivity.

function WStrIn( const S: WideString; const A: array of WideString ): Boolean;
Returns True, if S is "equal" to one of strings, taking place in A array. To check equality, WAnsiEq function is used, i.e. comaprison is taking place without case sensitivity.

function CharIn( C: KOLChar; const A: TSetOfChar ): Boolean;
To replace expressions like S[1] in [ '0'..'z' ] to CharIn( S[ 1 ], [ '0'..'z' ] ) (and to avoid problems with Unicode version of code).

function StrIs( const S: AnsiString; const A: Array of AnsiString; var Idx: Integer ): Boolean;
Returns True, if S is "equal" to one of strings, taking place in A array, and in such Case Idx also is assigned to an index of A element equal to S. To check equality, StrEq function is used, i.e. comaprison is taking place without case sensitivity.

function IntIn( Value: Integer; const List: array of Integer ): Boolean;
Returns TRUE, if Value is found in a List.

function _StrSatisfy( S, Mask: PKOLChar ): Boolean;

function _2StrSatisfy( S, Mask: PKOLChar ): Boolean;

function StrSatisfy( const S, Mask: KOLString ): Boolean;
Returns True, if S is satisfying to a given Mask (which can contain wildcard symbols '*' and '?' interpeted correspondently as 'any set of characters' and 'single any character'. If there are no such wildcard symbols in a Mask, result is True only if S is maching to Mask string.)

function StrReplace( var S: AnsiString; const From, ReplTo: AnsiString ): Boolean;
Replaces first occurance of From to ReplTo in S, returns True, if pattern From was found and replaced.

function KOLStrReplace( var S: KOLString; const From, ReplTo: KOLString ): Boolean;
Replaces first occurance of From to ReplTo in S, returns True, if pattern From was found and replaced.

function WStrReplace( var S: WideString; const From, ReplTo: WideString ): Boolean;
Replaces first occurance of From to ReplTo in S, returns True, if pattern From was found and replaced. See also function StrReplace. This function is not available in Delphi2 (this version of Delphi does not support WideString type).

function StrRepeat( const S: AnsiString; Count: Integer ): AnsiString;
Repeats given string Count times. E.g., StrRepeat( 'A', 5 ) gives 'AAAAA'.

function WStrRepeat( const S: WideString; Count: Integer ): WideString;
Repeats given wide string Count times. E.g., StrRepeat( 'A', 5 ) gives 'AAAAA'.

procedure NormalizeUnixText( var S: AnsiString );
In the string S, replaces all occurances of character #10 (without leading #13) to the character #13.

procedure Koi8ToAnsi( s: PAnsiChar );
Converts Koi8 text to Ansi (in place)

function StrPCopy( Dest: PAnsiChar; const Source: Ansistring ): PAnsiChar;
Copyes Pascal-style string into null-terminaed one.

function StrLCopy( Dest: PAnsiChar; const Source: PAnsiChar; MaxLen: Cardinal ): PAnsiChar;
Copyes first MaxLen characters of Pascal-style string into null-terminated one.

function DelimiterLast( const Str, Delimiters: KOLString ): Integer;
Returns index of the last of delimiters given by same named parameter among characters of Str. If there are no delimiters found, length of Str is returned. This function is intended mainly to use in filename parsing functions.

function __DelimiterLast( Str, Delimiters: PKOLChar ): PKOLChar;
Returns address of the last of delimiters given by Delimiters parameter among characters of Str. If there are no delimeters found, position of the null terminator in Str is returned. This function is intended mainly to use in filename parsing functions.

function W__DelimiterLast( Str, Delimiters: PWideChar ): PWideChar;

function SkipSpaces( P: PKOLChar ): PKOLChar;
Skips all characters #1..' ' in a string.

function CompareMem( P1, P2: Pointer; Length: Integer ): Boolean;
Fast compare of two memory blocks.

function AllocMem( Size: Integer ): Pointer;
Allocates global memory and unlocks it.

procedure DisposeMem( var Addr: Pointer );
Locks global memory block given by pointer, and frees it. Does nothing, if the pointer is nil.


Text in clipboard operations

function ClipboardHasText: Boolean;
Returns true, if the clipboard contain text to paste from.

function Clipboard2Text: AnsiString;
If clipboard contains text, this function returns it for You.

function Clipboard2WText: WideString;
If clipboard contains text, this function returns it for You (as Unicode string).

function Text2Clipboard( const S: AnsiString ): Boolean;
Puts given string to a clipboard.

function WText2Clipboard( const WS: WideString ): Boolean;
Puts given Unicode string to a clipboard.


procedure SupportAnsiMnemonics( LocaleID: Integer );
Provides encoding to work with given locale. Call this global function to extend TControl.SupportMnemonics capability (also should be called for a form or for Applet variable).

Date and time handling

type TDateFormat =( dfShortDate, dfLongDate );
Date formats available to use in formatting date/time to string.

type TTimeFormatFlag =( tffNoMinutes, tffNoSeconds, tffNoMarker, tffForce24 );
Additional flags, used for formatting time.

type TTimeFormatFlags = Set of TTimeFormatFlag;
Set of flags, used for formatting time.

var MonthDays: array[ Boolean ] of TDayTable =(( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ),( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ) );
The MonthDays array can be used to quickly find the number of days in a month: MonthDays[IsLeapYear(Y), M].

var SecsPerDay = 24* 60* 60;
Seconds per day.

var MSecsPerDay = SecsPerDay* 1000;
Milliseconds per day.

var VCLDate0 = 693594;
Value to convert VCL "date 0" to KOL "date 0" and back. This value corresponds to 30-Dec-1899, 0:00:00. So, to convert VCL date to KOL date, just subtract this value from VCL date. And to convert back from KOL date to VCL date, add this value to KOL date.

function Now: TDateTime;
Returns local date and time on running PC.

function Date: TDateTime;
Returns todaylocal date.

procedure DecodeDateFully( DateTime: TDateTime; var Year, Month, Day, DayOfWeek: WORD );
Decodes date.

procedure DecodeDate( DateTime: TDateTime; var Year, Month, Day: WORD );
Decodes date.

function EncodeDate( Year, Month, Day: WORD; var DateTime: TDateTime ): Boolean;
Encodes date.

function CompareSystemTime( const D1, D2: TSystemTime ): Integer;
Compares to TSystemTime records. Returns -1, 0, or 1 if, correspondantly, D1 < D2, D1 = D2 and D1 > D2.

procedure IncDays( var SystemTime: TSystemTime; DaysNum: Integer );
Increases/decreases day in TSystemTime record onto given days count (can be negative).

procedure IncMonths( var SystemTime: TSystemTime; MonthsNum: Integer );
Increases/decreases month number in TSystemTime record onto given months count (can be negative). Correct result is not garantee if day number is incorrect for newly obtained month.

function IsLeapYear( Year: Integer ): Boolean;
Returns True, if given year is "leap" (i.e. has 29 days in the February).

function DayOfWeek( Date: TDateTime ): Integer;
Returns day of week (0..6) for given date.

function SystemTime2DateTime( const SystemTime: TSystemTime; var DateTime: TDateTime ): Boolean;
Converts TSystemTime record to XDateTime variable.

function DateTime2SystemTime( const DateTime: TDateTime; var SystemTime: TSystemTime ): Boolean;
Converts TDateTime variable to TSystemTime record.

function DateTime_System2Local( DTSys: TDateTime ): TDateTime;
Converts DTSys representing system time (+0 Grinvich) to local time.

function DateTime_Local2System( DTLoc: TDateTime ): TDateTime;
Converts DTLoc representing local time to system time (+0 Grinvich)

function FileTime2DateTime( const ft: TFileTime; var DT: TDateTime ): Boolean;

function DateTime2FileTime( DT: TDateTime; var ft: TFileTime ): Boolean;

procedure DivMod( Dividend: Integer; Divisor: Word; var Result, Remainder: Word );
Dividing of integer onto divisor with obtaining both result of division and remainder.

function SystemDate2Str( const SystemTime: TSystemTime; const LocaleID: DWORD; const DfltDateFormat: TDateFormat; const DateFormat: PKOLChar ): KOLString;
Formats date, stored in TSystemTime record into string, using given locale and date/time formatting flags. (E.g.: GetUserDefaultLangID).

function SystemTime2Str( const SystemTime: TSystemTime; const LocaleID: DWORD; const Flags: TTimeFormatFlags; const TimeFormat: PKOLChar ): KOLString;
Formats time, stored in TSystemTime record into string, using given locale and date/time formatting flags.

function Date2StrFmt( const Fmt: KOLString; D: TDateTime ): KOLString;
Represents date as a string correspondently to Fmt formatting string. See possible pictures in definition of the function Str2DateTimeFmt (the first part). If Fmt string is empty, default system date format for short date string used.

function Time2StrFmt( const Fmt: KOLString; D: TDateTime ): KOLString;
Represents time as a string correspondently to Fmt formatting string. See possible pictures in definition of the function Str2DateTimeFmt (the second part). If Fmt string is empty, default system time format for short date string used.

function DateTime2StrShort( D: TDateTime ): KOLString;
Formats date and time to string in short date format using current user locale.

function Str2DateTimeFmt( const sFmtStr, sS: KOLString ): TDateTime;
Restores date or/and time from string correspondently to a format string. Date and time formatting string can contain following pictures (case sensitive):

DATE PICTURES
d    Day of the month as digits without leading zeros for single digit days.
dd   Day of the month as digits with leading zeros for single digit days
ddd  Day of the week as a 3-letter abbreviation as specified by a
LOCALE_SABBREVDAYNAME value.
dddd Day of the week as specified by a LOCALE_SDAYNAME value.
M    Month as digits without leading zeros for single digit months.
MM   Month as digits with leading zeros for single digit months
MMM  Month as a three letter abbreviation as specified by a LOCALE_SABBREVMONTHNAME value.
MMMM Month as specified by a LOCALE_SMONTHNAME value.
y    Year represented only be the last digit.
yy   Year represented only be the last two digits.
yyyy Year represented by the full 4 digits.
gg   Period/era string as specified by the CAL_SERASTRING value. The gg
format picture in a date string is ignored if there is no associated era
string. In Enlish locales, usual values are BC or AD.
TIME PICTURES
h    Hours without leading zeros for single-digit hours (12-hour clock).
hh   Hours with leading zeros for single-digit hours (12-hour clock).
H    Hours without leading zeros for single-digit hours (24-hour clock).
HH   Hours with leading zeros for single-digit hours (24-hour clock).
m    Minutes without leading zeros for single-digit minutes.
mm   Minutes with leading zeros for single-digit minutes.
s    Seconds without leading zeros for single-digit seconds.
ss   Seconds with leading zeros for single-digit seconds.
t    One character–time marker string (usually P or A, in English locales).
tt   Multicharacter–time marker string (usually PM or AM, in English locales).
E.g., 'D, yyyy/MM/dd h:mm:ss'. See also Str2DateTimeShort function.

function Str2DateTimeShort( const S: KOLString ): TDateTime;
Restores date and time from string correspondently to current user locale.

function Str2DateTimeShortEx( const S: KOLString ): TDateTime;
Like Str2DateTimeShort above, but uses locale defined date and time separators to avoid recognizing time as a date in some cases.


File and directory routines

var ofOpenRead = O_RDONLY $80000000;
Use this flag (in combination with others) to open file for "read" only.

var ofOpenWrite = O_WRONLY $40000000;
Use this flag (in combination with others) to open file for "write" only.

var ofOpenReadWrite = O_RDWR $C0000000;
Use this flag (in combination with others) to open file for "read" and "write".

var ofShareExclusive = $10 $00;
Use this flag (in combination with others) to open file for exclusive use.

var ofShareDenyWrite = $20 $01;
Use this flag (in combination with others) to open file in share mode, when only attempts to open it in other process for "write" will be impossible. I.e., other processes could open this file simultaneously for read only access.

var ofShareDenyRead = 0 $02;
Use this flag (in combination with others) to open file in share mode, when only attempts to open it for "read" in other processes will be disabled. I.e., other processes could open it for "write" only access.

var ofShareDenyNone = $30 $03;
Use this flag (in combination with others) to open file in full sharing mode. I.e. any process will be able open this file using the same share flag.

var ofCreateNew = O_CREAT or O_TRUNC $100;
Default creation disposition. Use this flag for creating new file (usually for write access.

var ofCreateAlways = O_CREAT $200;
Use this flag (in combination with others) to open existing or creating new file. If existing file is opened, it is truncated to size 0.

var ofOpenExisting = 0 $300;
Use this flag (in combination with others) to open existing file only.

var ofOpenAlways = O_CREAT $400;
Use this flag (in combination with others) to open existing or create new (if such file is not yet exists).

var ofTruncateExisting = O_TRUNC $500;
Use this flag (in combination with others) to open existing file and truncate it to size 0.

var ofAttrReadOnly = 0 $10000;
Use this flag to create Read-Only file (?).

var ofAttrHidden = 0 $20000;
Use this flag to create hidden file.

var ofAttrSystem = 0 $40000;
Use this flag to create system file.

var ofAttrTemp = 0 $1000000;
Use this flag to create temp file.

var ofAttrArchive = 0 $200000;
Use this flag to create archive file.

var ofAttrCompressed = 0 $8000000;
Use this flag to create compressed file. Has effect only on NTFS, and only if ofAttrCompressed is not specified also.

var ofAttrOffline = 0 $10000000;
Use this flag to create offline file.

function WFileCreate( const FileName: WideString; OpenFlags: DWord ): THandle;

function FileCreate( const FileName: KOLString; OpenFlags: DWord ): THandle;
Call this function to open existing or create new file. OpenFlags parameter can be a combination of up to three flags (by one from each group:
ofOpenRead, ofOpenWrite, ofOpenReadWrite - 1st group. Here You decide wish You open file for read, write or read-and-write operations;
ofShareExclusive, ofShareDenyWrite, ofShareDenyRead, ofShareDenyNone -2nd group - sharing. Here You can mark out sharing mode, which is used to open file.
ofCreateNew, ofCreateAlways, ofOpenExisting, ofOpenAlways, ofTruncateExisting - 3rd group - creation disposition. Here You determine, either to create new or open existing file and if to truncate existing or not.

function FileClose( Handle: THandle ): Boolean;
Call it to close opened earlier file.

function FileExists( const FileName: KOLString ): Boolean;
Returns True, if given file exists.
Note (by Dod): It is not documented in a help for GetFileAttributes, but it seems that under NT-based Windows systems, FALSE is always returned for files opened for excluseve use like pagefile.sys.

function WFileExists( const FileName: WideString ): Boolean;
Returns True, if given file exists.
Note (by Dod): It is not documented in a help for GetFileAttributes, but it seems that under NT-based Windows systems, FALSE is always returned for files opened for excluseve use like pagefile.sys.

function FileSeek( Handle: THandle; const MoveTo: TStrmMove; MoveMethod: TMoveMethod ): TStrmSize;
Changes current position in file.

function FileRead( Handle: THandle; var Buffer; Count: DWord ): DWord;
Reads bytes from current position in file to buffer. Returns number of read bytes.

function File2Str( Handle: THandle ): AnsiString;
Reads file from current position to the end and returns result as ansi string.

function File2WStr( Handle: THandle ): WideString;
Reads UNICODE file from current position to the end and returns result as unicode string.

function FileWrite( Handle: THandle; const Buffer; Count: DWord ): DWord;
Writes bytes from buffer to file from current position, extending its size if needed.

function FileEOF( Handle: THandle ): Boolean;
Returns True, if EOF is achieved during read operations or last byte is overwritten or append made to extend file during last write operation.

function FileFullPath( const FileName: KOLString ): KOLString;
Returns full path name for given file. Validness of source FileName path is not checked at all.

function FileShortPath( const FileName: KOLString ): KOLString;
Returns short path to the file or directory.

function FileIconSystemIdx( const Path: KOLString ): Integer;
Returns index of the index of the system icon correspondent to the file or directory in system icon image list.

function FileIconSysIdxOffline( const Path: KOLString ): Integer;
The same as FileIconSystemIdx, but an icon is calculated for the file as it were offline (it is possible to get an icon for file even if it is not existing, on base of its extension only).

function DirIconSysIdxOffline( const Path: KOLString ): Integer;
The same as FileIconSysIdxOffline, but for a folder rather then for a file.

procedure LogFileOutput( const filepath, str: KOLString );
Debug function. Use it to append given string to the end of the given file.

function Str2File( Filename: PKOLChar; Str: PAnsiChar ): Boolean;
Save null-terminated string to file directly. If file does not exists, it is created. If it exists, it is overriden. If operation failed, FALSE is returned.

function WStr2File( Filename: PKOLChar; Str: PWideChar ): Boolean;
Save null-terminated wide string to file directly. If file does not exists, it is created. If it exists, it is overriden. If operation failed, FALSE is returned.

function StrSaveToFile( const Filename: KOLString; const Str: AnsiString ): Boolean;
Saves a string to a file without any changes. If file does not exists, it is created. If it exists, it is overriden. If operation failed, FALSE is returned.

function StrLoadFromFile( const Filename: KOLString ): AnsiString;
Reads entire file and returns its content as a string. If operation failed, an empty strinng is returned.
by Sergey Shishmintzev: it is possible to pass Filename = 'CON' to read input from redirected console output.

function WStrSaveToFile( const Filename: KOLString; const Str: WideString ): Boolean;
Saves a string to a file without any changes. If file does not exists, it is created. If it exists, it is overriden. If operation failed, FALSE is returned.

function WStrLoadFromFile( const Filename: KOLString ): WideString;
Reads entire file and returns its content as a string. If operation failed, an empty strinng is returned.
by Sergey Shishmintzev: it is possible to pass Filename = 'CON' to read input from redirected console output.

function Mem2File( Filename: PKOLChar; Mem: Pointer; Len: Integer ): Integer;
Saves memory block to a file (if file exists it is overriden, created new if not exists).

function File2Mem( Filename: PKOLChar; Mem: Pointer; MaxLen: Integer ): Integer;
Loads file content to memory.

procedure FileTime( const Path: KOLString; CreateTime, LastAccessTime, LastModifyTime: PFileTime );
Returns file times without opening it.

function GetUniqueFilename( PathName: KOLString ): KOLString;
If file given by PathName exists, modifies it to create unique filename in target folder and returns it. Modification is performed by incrementing last number in name (if name part of file does not represent a number, such number is generated and concatenated to it). E.g., if file aaa.aaa is already exist, the function checks names aaa1.aaa, aaa2.aaa, ..., aaa10.aaa, etc. For name abc123.ext, names abc124.ext, abc125.ext, etc. will be checked.

function FileTimeCompare( const FT1, FT2: TFileTime ): Integer;
Compares time of file (createing, writing, accessing. Returns -1, 0, 1 if correspondantly FT1<FT2, FT1=FT2, FT1>FT2.

function DirectoryExists( const Name: KOLString ): Boolean;
Returns True if given directory (folder) exists.

function DiskPresent( const DrivePath: KOLString ): Boolean;
Returns TRUE if the disk is present

function WDirectoryExists( const Name: WideString ): Boolean;

function CheckDirectoryContent( const Name: KOLString; SubDirsOnly: Boolean; const Mask: AnsiString ): Boolean;
Returns TRUE if directory does not contain files (or directories only) satisfying given mask.

function DirectoryEmpty( const Name: KOLString ): Boolean;
Returns True if given directory is not exists or empty.

function DirectoryHasSubdirs( const Path: KOLString ): Boolean;
Returns TRUE if given directory exists and has subdirectories.

function GetStartDir: KOLString;
Returns path to directory where executable is located (regardless of current directory).

function ExePath: KOLString;
Returns the path to the exe-file (in case of dll hook, this is exe-file of the process in which context dll hook function is called).

function ModulePath: KOLString;
Returns the path to the module (exe, dll) itself.

function ExcludeTrailingChar( const S: KOLString; C: KOLChar ): KOLString;
If S is finished with character C, it is excluded.

function IncludeTrailingChar( const S: KOLString; C: KOLChar ): KOLString;
If S is not finished with character C, it is added.

function IncludeTrailingPathDelimiter( const S: KOLString ): KOLString;
by Edward Aretino. Adds '\' to the end if it is not present.

function ExcludeTrailingPathDelimiter( const S: KOLString ): KOLString;
by Edward Aretino. Removes '\' at the end if it is present.

function ExtractFileDrive( const Path: KOLString ): KOLString;
Returns only drive part from exact path to a file or a directory. For network paths, returns a computer name together with a following name of shared directory (like '\\compname\shared\' ).

function ExtractFilePath( const Path: KOLString ): KOLString;
Returns only path part from exact path to file.

function WExtractFilePath( const Path: WideString ): WideString;
Returns only path part from exact path to file.

function IsNetworkPath( const Path: KOLString ): Boolean;
Returns TRUE, if Path is starting from '\\'.

function ExtractFileName( const Path: KOLString ): KOLString;
Extracts file name from exact path to file.

function ExtractFileNameWOext( const Path: KOLString ): KOLString;
Extracts file name from path to file or from filename.

function ExtractFileExt( const Path: KOLString ): KOLString;
Extracts extention from file name (returns it with dot '.' first)

function ReplaceExt( const Path, NewExt: KOLString ): KOLString;
Returns Path to a file with extension replaced to a new extension. Pass a new extension started with '.', e.g. '.txt'.

function ForceDirectories( Dir: KOLString ): Boolean;
by Edward Aretino. Creates given directory if not present. All needed subdirectories are created if necessary.

function CreateDir( const Dir: KOLString ): Boolean;
by Edward Aretino. Creates given directory.

function ChangeFileExt( FileName: KOLString; const Extension: KOLString ): KOLString;
by Edward Aretino. Changes file extention.

function ReplaceFileExt( const Path, NewExt: KOLString ): KOLString;
Returns a path with extension replaced to a given one.

function ExtractShortPathName( const Path: KOLString ): KOLString;

function FilePathShortened( const Path: KOLString; MaxLen: Integer ): KOLString;
Returns shortened file path to fit MaxLen characters.

function FilePathShortenPixels( const Path: KOLString; DC: HDC; MaxPixels: Integer ): KOLString;
Returns shortened file path to fit MaxPixels for a given DC. If you pass Canvas.Handle of any control or bitmap object, ensure that font is valid for it (or call TCanvas.RequiredState( FontValid ) method before. If DC passed = 0, call is equivalent to call FilePathShortened, and MaxPixels means in such case maximum number of characters.

function MinimizeName( const Path: KOLString; DC: HDC; MaxPixels: Integer ): KOLString;
Exactly the same as MinimizeName in FileCtrl.pas (VCL).

function GetSystemDir: KOLString;
Returns path to windows system directory.

function GetWindowsDir: KOLString;
Returns path to Windows directory.

function GetWorkDir: KOLString;
Returns path to application's working directory.

function GetTempDir: KOLString;
Returns path to default temp folder (directory to place temporary files).

function CreateTempFile( const DirPath, Prefix: KOLString ): KOLString;
Returns path to just created temporary file.

function GetFileListStr( FPath, FMask: KOLString ): KOLString;
List of files in string, separating each path from others with a character stored in FileOpSeparator variables (#13 by default). E.g.: 'c:\tmp\unit1.dcu'#13'c:\tmp\unit1.~pa' (for use with DeleteFile2Recycle())

function DeleteFiles( const DirPath: KOLString ): Boolean;
Deletes files by file mask (given with wildcards '*' and '?').

function DoFileOp( const FromList, ToList: KOLString; FileOp: UINT; Flags: Word; Title: PKOLChar ): Boolean;
By Unknown Mystic. FileOp can be: FO_MOVE, FO_COPY, FO_DELETE, FO_RENAME. Flags can be a combination of values: FOF_MULTIDESTFILES, FOF_CONFIRMMOUSE, FOF_SILENT, FOF_RENAMEONCOLLISION, FOF_NOCONFIRMATION, FOF_WANTMAPPINGHANDLE, FOF_ALLOWUNDO, FOF_FILESONLY, FOF_SIMPLEPROGRESS, FOF_NOCONFIRMMKDIR, FOF_NOERRORUI. Title used only with FOF_SIMPLEPROGRESS.

function DeleteFile2Recycle( const Filename: KOLString ): Boolean;
Deletes file to recycle bin. This operation can be very slow, when called for a single file. To delete group of files at once (fast), pass a list of paths to files to be deleted, separating each path from others with a character stored in FileOpSeparator variable (by default #13, but in case when OLD_COMPAT symbol added - ';'). E.g.: 'unit1.dcu'#13'unit1.~pa'
FALSE is returned only in case when at least one file was not deleted successfully.
Note, that files are deleted not to recycle bin, if wildcards are used or not fully qualified paths to files.

function CopyMoveFiles( const FromList, ToList: KOLString; Move: Boolean ): Boolean;

function DiskFreeSpace( const Path: KOLString ): I64;
Returns disk free space in bytes. Pass a path to root directory, e.g. 'C:\'.


Wrappers to registry API functions

These functions can be used independently to simplify access to Windows registry.

function RegKeyOpenRead( Key: HKey; const SubKey: KOLString ): HKey;
Opens registry key for read operations (including enumerating of subkeys). Pass either handle of opened earlier key or one of constans HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS as a first parameter. If not successful, 0 is returned.

function RegKeyOpenWrite( Key: HKey; const SubKey: KOLString ): HKey;
Opens registry key for write operations (including adding new values or subkeys), as well as for read operations too. See also RegKeyOpenRead.

function RegKeyOpenCreate( Key: HKey; const SubKey: KOLString ): HKey;
Creates and opens key.

function RegKeyGetStr( Key: HKey; const ValueName: KOLString ): KOLString;
Reads key, which must have type REG_SZ (null-terminated string). If not successful, empty string is returned. This function as well as all other registry manipulation functions, does nothing, if Key passed is 0 (without producing any error).

function RegKeyGetStrEx( Key: HKey; const ValueName: KOLString ): KOLString;
Like RegKeyGetStr, but accepts REG_EXPAND_SZ type, expanding all environment variables in resulting string.
Code provided by neuron, e-mailto:neuron@hollowtube.mine.nu

function RegKeyGetDw( Key: HKey; const ValueName: KOLString ): DWORD;
Reads key value, which must have type REG_DWORD. If ValueName passed is '' (empty string), unnamed (default) value is reading. If not successful, 0 is returned.

function RegKeySetStr( Key: HKey; const ValueName: KOLString; const Value: KOLString ): Boolean;
Writes new key value as null-terminated string (type REG_SZ). If not successful, returns False.

function RegKeySetStrEx( Key: HKey; const ValueName: KOLString; const Value: KOLString; expand: Boolean ): Boolean;
Writes new key value as REG_SZ or REG_EXPAND_SZ. - by neuron, e-mailto:neuron@hollowtube.mine.nu

function RegKeySetDw( Key: HKey; const ValueName: KOLString; Value: DWORD ): Boolean;
Writes new key value as dword (with type REG_DWORD). Returns False, if not successful.

procedure RegKeyClose( Key: HKey );
Closes key, opened using RegKeyOpenRead or RegKeyOpenWrite. (But does nothing, if Key passed is 0).

function RegKeyDelete( Key: HKey; const SubKey: KOLString ): Boolean;
Deletes key. Does nothing if key passed is 0 (returns FALSE).

function RegKeyDeleteValue( Key: HKey; const SubKey: KOLString ): Boolean;
Deletes value. - by neuron, e-mailto:neuron@hollowtube.mine.nu

function RegKeyExists( Key: HKey; const SubKey: AnsiString ): Boolean;
Returns TRUE, if given subkey exists under given Key.

function RegKeyValExists( Key: HKey; const ValueName: KOLString ): Boolean;
Returns TRUE, if given value exists under the Key.

function RegKeyValueSize( Key: HKey; const ValueName: KOLString ): Integer;
Returns a size of value. This is a size of buffer needed to store registry key value. For string value, size returned is equal to a length of string plus 1 for terminated null character.

function RegKeyGetBinary( Key: HKey; const ValueName: KOLString; var Buffer; Count: Integer ): Integer;
Reads binary data from a registry, writing it to the Buffer. It is supposed that size of Buffer provided is at least Count bytes. Returned value is actul count of bytes read from the registry and written to the Buffer.
This function can be used to get data of any type from the registry, not only REG_BINARY.

function RegKeySetBinary( Key: HKey; const ValueName: KOLString; const Buffer; Count: Integer ): Boolean;
Stores binary data in the registry.

function RegKeyGetDateTime( Key: HKey; const ValueName: KOLString ): TDateTime;
Returns datetime variable stored in registry in binary format.

function RegKeySetDateTime( Key: HKey; const ValueName: KOLString; DateTime: TDateTime ): Boolean;
Stores DateTime variable in the registry.

function RegKeyGetSubKeys( const Key: HKEY; List: PKOLStrList ): Boolean;
The function enumerates subkeys of the specified open registry key. True is returned, if successful.

function RegKeyGetValueNames( const Key: HKEY; List: PKOLStrList ): Boolean;
The function enumerates value names of the specified open registry key. True is returned, if successful.

function RegKeyGetValueTyp( const Key: HKEY; const ValueName: KOLString ): DWORD;
The function receives the type of data stored in the specified value.
If the function fails, the return value is the Key value.
If the function succeeds, the return value return will be one of the following:
REG_BINARY , REG_DWORD, REG_DWORD_LITTLE_ENDIAN, REG_DWORD_BIG_ENDIAN, REG_EXPAND_SZ, REG_LINK , REG_MULTI_SZ, REG_NONE, REG_RESOURCE_LIST, REG_SZ


Data sorting (quicksort implementation)

This part contains implementation of 'quick sort' algorithm, based on following code:
 TQSort by Mike Junkin 10/19/95.
 DoQSort routine adapted from Peter Szymiczek's QSort procedure which
 was presented in issue#8 of The Unofficial Delphi Newsletter.
 TQSort changed by Vladimir Kladov (Mr.Bonanzas) to allow 32-bit
 sorting (of big arrays with more than 64K elements).
Finally, this sort procedure is adapted to XCL (and then to KOL) requirements (no references to SysUtils, Classes etc. TQSort object is transferred to a single procedure call and DoQSort method is renamed to SortData - which is a regular procedure now).

type TCompareEvent = function( const Data: Pointer; const e1, e2: Dword ): Integer;
Event type to define comparison function between two elements of an array. This event handler must return -1 or +1 (correspondently for cases e1<e2 and e2>e2). Items are enumerated from 0 to uNElem.

type TSwapEvent = procedure( const Data: Pointer; const e1, e2: Dword );
Event type to define swap procedure which is swapping two elements of an array.

procedure SortData( const Data: Pointer; const uNElem: Dword; const CompareFun: TCompareEvent; const SwapProc: TSwapEvent );
Call it to sort any array of data of any kind, passing total number of items in an array and two defined (regular) function and procedure to perform custom compare and swap operations. First procedure parameter is to pass it to callback function CompareFun and procedure SwapProc. Items are enumerated from 0 to uNElem-1.

procedure SwapListItems( const L: Pointer; const e1, e2: DWORD );
Use this function as the last parameter for SortData call when a PList object is sorting. SwapListItems just exchanges two items of the list.

procedure SortIntegerArray( var A: array of Integer );
procedure to sort array of integers.

procedure SortDwordArray( var A: array of DWORD );
Procedure to sort array of unsigned 32-bit integers.


type TSortDirRules =( sdrNone, sdrFoldersFirst, sdrCaseSensitive, sdrByName, sdrByExt, sdrBySize, sdrBySizeDescending, sdrByDateCreate, sdrByDateChanged, sdrByDateAccessed );
List of rules (options) to sort directories. Rules are passed to Sort method in an array, and first placed rules are applied first.

function NewDirList( const DirPath, Filter: KOLString; Attr: DWORD ): PDirList;
Creates directory list object using easy one-string filter. If Attr = FILE_ATTRIBUTE_NORMAL, only files are scanned without directories. If Attr = 0, both files and directories are listed.

function NewDirListEx( const DirPath, Filters: KOLString; Attr: DWORD ): PDirList;
Creates directory list object using several filters, separated by ';'. Filters starting from '^' consider to be anti-filters, i.e. files, satisfying to those masks, are skept during scanning.

var DefSortDirRules: array[ 0 . . 3 ] of TSortDirRules =( sdrFoldersFirst, sdrByName, sdrBySize, sdrByDateCreate );
Default rules to sort directory entries.

function DirectorySize( const Path: KOLString ): I64;
Returns directory size in bytes as large 64 bit integer.

type TOpenSaveOptions = set of TOpenSaveOption;
Options available for TOpenSaveDialog.

function NewOpenSaveDialog( const Title, StrtDir: KOLString; Options: TOpenSaveOptions ): POpenSaveDialog;
Creates object, which can be used (several times) to open file(s) selecting dialog.

type TOpenDirOption =( odBrowseForComputer, odBrowseForPrinter, odDontGoBelowDomain, odOnlyFileSystemAncestors, odOnlySystemDirs, odStatusText, odBrowseIncludeFiles, odEditBox, odNewDialogStyle );
Flags available for TOpenDirDialog object.

type TOpenDirOptions = set of TOpenDirOption;
Set of all flags used to control ZOpenDirDialog class.

type TOnODSelChange = procedure( Sender: POpenDirDialog; NewSelDir: PKOL_Char; var EnableOK: Integer; var StatusText: KOL_String ) of object;
Event type to be called when user select another directory in OpenDirDialog. Set EnableOK to -1 to disable OK button, or to +1 to enable it. It is also possible to set new StatusText string.

function NewOpenDirDialog( const Title: KOLString; Options: TOpenDirOptions ): POpenDirDialog;
Creates object, which can be used (several times) to open directory selecting dialog (using SHBrowseForFolder API call).

function NewColorDialog( FullOpen: TColorCustomOption ): PColorDialog;
Creates color choosing dialog object.

type TIniFileMode =( ifmRead, ifmWrite );
ifmRead is default mode (means "read" data from ini-file. Set mode to ifmWrite to write data to ini-file, correspondent to TIniFile.

function OpenIniFile( const FileName: KOLString ): PIniFile;
Opens ini file, creating TIniFile object instance to work with it.

type TOnMenuItem = procedure( Sender: PMenu; Item: Integer ) of object;
Event type to define OnMenuItem event.

type TMenuAccelerator = packed Record
Menu accelerator record. Use MakeAccelerator function to combine desired attributes into a record, describing the accelerator.
  fVirt: Byte; or-combination of FSHIFT, FCONTROL, FALT, FVIRTKEY, FNOINVERT
  Key: Word; character or virtual key code (FVIRTKEY flag is present above)
  NotUsed: Byte; not used
end;

type TMenuOption =( moDefault, moDisabled, moChecked, moCheckMark, moRadioMark, moSeparator, moBitmap, moSubMenu, moBreak, moBarBreak );
Options to add menu items dynamically.

type TMenuOptions = set of TMenuOption;
Set of options for menu item to use it in TMenu.AddItem method.

type TMenuBreak =( mbrNone, mbrBreak, mbrBarBreak );
Possible menu item break types.

function MenuStructSize: Integer;
Returns 44 under Windows95, and 48 (=sizeof(TMenuItemInfo) under all other Windows versions.

function NewMenu( AParent: PControl; MaxCmdReserve: DWORD; const Template: array of PKOLChar; aOnMenuItem: TOnMenuItem ): PMenu;
Menu constructor. First created menu becomes main menu of form (if AParent is a form). All other menus becomes popup (can be activated using Popup method). To provide dynamic replacing of main menu, create all popup menus as children of any other control, not form itself. When Menu is created, pass FirstCmd integer value to set it as ID of first menu item (all other ID's obtained by incrementing this value), and Template, which is an array of PChar (usually array of string constants), containing list of menu item identifiers and/or formatting characters.
    FirstCmd value is assigned to first menu item created as its ID, all follow menu items are assigned to ID's obtained from FirstCmd incrementing it by 1. It is desirable to provide not intersected ranges of ID's for defferent menus in the applet.
    Following formatting characters can be used in menu template strings:
& (in identifier) - to underline next character and use it as a shortcut character when possible;
+ (in front of identifier) - to make item checked. If also ! is used before & than radioitem is defined;
- (in front of identifier) - item not checked;
- (separate) - separator (between two items);
( (separate) - start of submenu;
) (separate) - end of submenu;
    To get access to menu items, use constants 0, 1, etc. It is a good idea to create special enumerated type to index correspondent menu items using Ord( ) operator. Note in that case, that it is necessary only to define constants correspondent to identifiers (positions, correspondent to separators or submenu brackets are not identified by numbers).
   

function NewMenuEx( AParent: PControl; FirstCmd: Integer; const Template: array of PKOLChar; aOnMenuItems: array of TOnMenuItem ): PMenu;
Creates menu, assigning its own event handler for every (enough) menu item.

function MakeAccelerator( fVirt: Byte; Key: Word ): TMenuAccelerator;
Creates accelerator item to assign it to TMenu.ItemAccelerator[ ] property easy.

function GetAcceleratorText( const Accelerator: TMenuAccelerator ): KOLString;
Returns text representation of accelerator.


System functions and working with windows

type TWindowChildKind =( wcActive, wcFocus, wcCapture, wcMenuOwner, wcMoveSize, wcCaret );
Type of window child kind. Used in function GetWindowChild.

function GetWindowChild( Wnd: HWnd; Kind: TWindowChildKind ): HWnd;
Returns child of given top-level window, having given characteristics. For example, it is possible to get know for foreground window, which of its child window has focus. This function does not work in old Windows 95 (returns Wnd in that case). But for Windows 98, Windows NT/2000 this function works fine. To obtain focused child of the window, use GetFocusedWindow, which is independant from Windows version.

function GetFocusedChild( Wnd: HWnd ): HWnd;
Returns focused child of given window (which should be foreground and active, certainly). 0 is returned either if Wnd is not active or Wnd has no focused child window.

function Stroke2Window( Wnd: HWnd; const S: AnsiString ): Boolean;
Posts characters from string S to those child window of Wnd, which has focus now (top-level window Wnd must be foreground, and have focused edit-aware control to receive the stroke).
This function allows only to post typeable characters (including such special symbols as #13 (Enter), #9 (Tab), #8 (BackSpace), etc.
See also function Stroke2WindowEx, which allows to post any key down and up events, simulating keyboard for given (automated) application.

function Stroke2WindowEx( Wnd: HWnd; const S: AnsiString; Wait: Boolean ): Boolean;
In addition to function Stroke2Window, this one can send special keys to given window, including functional keys and navigation keys. To post special key to target window, place a combination of names of such key together with keys, which should be passed simultaneously, between square or figure brackets. For example, [Ctrl F1], [Alt Shift Home], [Ctrl E]. For letters and usual characters, it is not necessary to simulate pressing it with determining all Shift combinations and it is sufficient to pass characters as is. (E.g., not '[Shift 1]', but '!').

function FindWindowByThreadID( ThreadID: DWORD ): HWnd;
Searches for window, belonging to a given thread.

function DesktopPixelFormat: TPixelFormat;
Returns the pixel format correspondent to current desktop color resolution. Use this function to decide which format to use for converting bitmap, planned to draw transparently using TBitmap.DrawTransparent or TBitmap.StretchDrawTransparent methods.

function GetDesktopRect: TRect;
Returns rectangle of screen, free of taskbar and other similar app-bars, which reduces size of available desktop when created.

function GetWorkArea: TRect;
The same as GetDesktopRect, but obtained calling SystemParametersInfo.

function ExecuteWait( const AppPath, CmdLine, DfltDirectory: KOLString; Show: DWORD; TimeOut: DWORD; ProcID: PDWORD ): Boolean;
Allows to execute an application and wait when it is finished. Pass INFINITE constant as TimeOut, if You sure that application is finished anyway. If another value passed as a TimeOut (in milliseconds), and application was not finished for that time, ExecuteWait is returning FALSE, and if ProcID is not nil, than ProcID^ contains started process handle (it can be used to wait it more, or to terminate it using TerminateProcess API function).
Launching application can be console or GUI - it does not matter. Pass SW_SHOW, SW_HIDE or other SW_XXX constant as Show parameter as appropriate.
True is returned only in case when application specified was launched successfully and finished for TimeOut specified. Otherwise, check ProcID^ variable: if it is 0, process could not be launched (and it is possible to get information about error using GetLastError API function in a such case). You can freely pass nil in place of ProcID parameter, but this is acually correct only when TimeOut is INFINITE.

function ExecuteIORedirect( const AppPath, CmdLine, DfltDirectory: KOLString; Show: DWORD; ProcID: PDWORD; InPipe, OutPipeWr, OutPipeRd: PHandle ): Boolean;
Executes an application with its console input and output redirection. Terminating of the application is not waiting, but if ProcID pointer is defined, it receives process Id launched, so it is possible to call WaitForSingleObject for it. InPipe is a pointer to THandle variable which receives a handle to input pipe of the console redirected. The same is for OutPipeWr and OutPipeRd, but for output of the console redirected. Before reading from OutPipeRd^, first close OutPipeWr^. If you run simple console application, for which you want to read results after its termination, you can use ExecuteConsoleAppIORedirect instead.
    Notes: if your application is not console and it does not create console using AllocConsole, this function will fail to redirect input-output.

function ExecuteConsoleAppIORedirect( const AppPath, CmdLine, DfltDirectory: AnsiString; Show: DWORD; const InStr: AnsiString; var OutStr: AnsiString; WaitTimeout: DWORD ): Boolean;
Executes an application, redirecting its console input and output. After redirecting input and output and launching the application, content of InStr is written to input stream of the application, then the application is waiting for its termination (WaitTimeout milliseconds or INFINITE, as passed) and console output of the application is read to OutStr. TRUE is returned only in case, when all these tasks are completed successfully.
    Notes: if your application is not console and it does not create console using AllocConsole, this function will fail to redirect input-output.

function WindowsShutdown( const Machine: KOLString; Force, Reboot: Boolean ): Boolean;
Shut down of Windows NT. Pass Machine = '' to shutdown this PC. Pass Reboot = True to reboot immediatelly after shut down.

function WindowsLogoff( Force: Boolean ): Boolean;
Logoff of Windows.

type TWindowsVersion =( wv31, wv95, wv98, wvME, wvNT, wvY2K, wvXP, wvServer2003, wvVista, wvSeven );
Windows versions constants.

type TWindowsVersions = Set of TWindowsVersion;
Set of Windows version (e.g. to define a range of versions supported by the application).

function WinVer: TWindowsVersion;
Returns Windows version.

function IsWinVer( Ver: TWindowsVersions ): Boolean;
Returns True if Windows version is in given range of values.

function ParamStr( Idx: Integer ): KOLString;
Returns command-line parameter by index. This function supersides standard ParamStr function.

function ParamCount: Integer;
Returns number of parameters in command line.


function CrackStack_MapInResource( const MapName: KOLString; Max_length: Integer; HandleSuspiciousAddresses: Boolean ): KOLString;
Allows to list all procedures and functions called before current cracking stack frames. This version loads map-file from the resource. Important note: you must provide latest map file created at the last application build in the resource! See also CrackStack_MapInFile below.

function CrackStack_MapInFile( const MapFileName: KOLString; Max_length: Integer; HandleSuspiciousAddresses: Boolean ): KOLString;
Allows to list all procedures and functions called before current cracking stack frames. This version loads map-file from the file. Important note: you must have the latest map file created at the last application build on a path specified! For example, use path GetStartDir + appname_wo_extention + '.map' and do not forget to set flag Map file - Detailed in Project Options ¦ Linker. Use flag HandleSuspiciousAddresses to show all suspicious addresses found in stack (this may help to find errors not shown even by Delphi debugger since stack frames in some cases give no enough data).

type _TObj = object
auxiliary object type. See TObj.

type TObj = object( _TObj )
Prototype for all objects of KOL. All its methods are important to implement objects in a manner similar to Delphi TObject class.

type TList = object( TObj )
Simple list of pointers. It is used in KOL instead of standard VCL TList to store any kind data (or pointers to these ones). Can be created calling function NewList.

type TStrList = object( TObj )
Easy string list implementation (non-visual, just to store string data). It is well improved and has very high performance allowing to work fast with huge text files (more then megabyte of text data). Please note that #0 charaster if stored in string lines, will cut it preventing reading the rest of a line. Be careful, if your data contain such characters.

type TStrListEx = object( TStrList )
Extended string list object. Has additional capability to associate numbers or objects with string list items.

type TWStrList = object( TObj )
String list to store Unicode (null-terminated) strings.

type TWStrListEx = object( TWStrList )
Extended Unicode string list (with Objects).

type TGraphicTool = object( TObj )
Incapsulates all GDI objects: Pen, Brush and Font.

type TCanvas = object( TObj )
Very similar to VCL's TCanvas object. But with some changes, specific for KOL: there is no necessary to use canvases in all applications. And graphic tools objects are not created with canvas, but only if really accessed in program. (Actually, even if paint box used, only programmer decides, if to implement painting using Canvas or to call low level API drawing functions working directly with DC). Therefore TCanvas has some powerful extensions: rotated text support, geometric pen support - just by changing correspondent properties of certain graphic tool objects (Font.FontOrientation, Pen.GeometricPen). See also additional Font properties (Font.FontWeight, Font.FontQuality, etc.

type TImageList = object( TObj )
ImageList incapsulation.

type TBitmap = object( TObj )
Bitmap incapsulation object.

type TIcon = object( TObj )
Object type to incapsulate icon or cursor image.

type TControl = object( TObj )
TControl is the basic visual object of KOL. And now, all visual objects have the same type PControl, differing only in "constructor", which during creating of object adjusts it so it can play role of desired control. Idea of incapsulating of all visual objects having the most common set of properties, is belonging to Vladimir Kladov, (C) 2000.
    Since all visual objects are represented in KOL by this single object type, not all methods, properties and events defined in TControl, are applicable to different visual objects. See also notes about certain control kinds, located together with its constructing functions definitions.

type TTimer = object( TObj )
Easy timer incapsulation object. It uses separate topmost window, common for all timers in the application, to handle WM_TIMER message. This allows using timers in non-windowed application (but anyway it should contain message handling loop for a thread).
Note: in UNIX, there are no special windows created, certainly.

type TMMTimer = object( TTimer )
Multimedia timer incapsulation object. Does not require Applet or special window to handle it. System creates a thread for each high resolution timer, so using many such objects can degrade total PC performance.

type TTrayIcon = object( TObj )
Object to place (and change) a single icon onto taskbar tray.

type TDirList = object( TObj )
Allows easy directory scanning. This is not visual object, but storage to simplify working with directory content.

type TOpenSaveDialog = object( TObj )
Object to show standard Open/Save dialog. Initially provided for XCL by Carlo Kok.

type TOpenDirDialog = object( TObj )
Dialog for open directories, uses SHBrowseForFolder.

type TColorDialog = object( TObj )
Color choosing dialog.

type TIniFile = object( TObj )
Ini file incapsulation. The main feature is what the same block of read-write operations could be defined (difference must be only in Mode value).    µ   


Index ]

This help is generated 14-Jun-2010 by KOL Help generator, (C) 2000-2001 by Vladimir Kladov
Modified (C) 2003 by Alexander Bartov