Unit rtool

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

rtool is set of variety functions (strings, datetimes, forms, cursor, printers, system routines).

Updated version compatible with Delphi2010+.

Overview

Functions and Procedures

function WideStringToString(const ws: WideString; codePage: Word): AnsiString;
function StringToWideString(const s: AnsiString; codePage: Word): WideString;
function GetDecimalSeparator: Char;
function GetThousandSeparator: Char;
function GetDateSeparator: Char;
function GetThemeServices: TCustomStyleServices;
function GetThemeEnabled: Boolean;
function UpdateToDecimalSeparator(const s: string): string;
procedure DPI_SetFontHeight(AFont: TFont);
procedure DPI_ScaleFontHeight(AFont: TFont; M, D: integer); overload;
procedure DPI_ScaleFontHeight(AFont: TFont; ScaleRatio: double); overload;
function FillStrL(const s: string; By: Char; Len: integer): string;
function FillStrR(const s: string; By: Char; Len: integer): string;
function AnsiPosEx(const Substr, s: string; From: integer = 1; CaseSensitive: Boolean = false): integer;
function FindStrPart(const s, Separator: string; Sequence: byte; CaseSensitive: Boolean = false): string;
function RemoveStrPart(var s: string; const Separator: string; CaseSensitive: Boolean = false): string;
function FindStrFromTo(const SubstrStart, SubstrStop, s: string; CaseSensitive: Boolean = false; ExtractSubstrStart: Boolean = false): string;
function ClearStr(const Substr, s: string; CaseSensitive: Boolean = false): string;
function ReplaceStr(const OldSubstr, NewSubstr, s: string; All: Boolean = true; CaseSensitive: Boolean = false): string;
function ReplaceStrFromTo(const OldSubstrStart, OldSubstrStop, NewSubstr, s: string; ReplaceSubstrStop: Boolean = true; All: Boolean = true; CaseSensitive: Boolean = false): string;
procedure AddToSepList(var List: string; const StrToAdd: string; const Sep: string = ', ');
function ContainWholeWord(const Substr, s: string; Separators: TSysCharSet; StartPos: integer = 0): Boolean;
function VarToString(PointToVar: Pointer; LengthVar: integer): string;
function StringToVar(PointToVar: Pointer; LengthVar: integer; s: string): Boolean;
function GetLine(const StrList: string; Index: integer): string;
function SetLine(const StrList, Line: string; Index: integer): string;
function IntToStr0(Int: integer; Len: integer): string;
function CreateF(const FormClass: TFormClass; var Ref; AddToFormList: Boolean = true): Boolean;
function FreeF(var Ref): Boolean;
function CreateShowFM(const FormClass: TFormClass; var Ref): integer;
procedure CreateShowF(const FormClass: TFormClass; var Ref);
procedure FreeAllF;
function GetActiveOwner: TComponent;
procedure FocusNextControl(Form: TForm);
function ShowWinHelp(Form: TForm; Command: Word; Data: integer; var CallHelp: Boolean): Boolean;
function ShowExtHelp(Form: TForm; Command: Word; Data: integer; var CallHelp: Boolean): Boolean;
function CreateMenuItem(Owner: TComponent; Caption: string; Tag: integer; OnClick: TNotifyEvent): TMenuItem; overload;
function CreateMenuItem(Owner: TComponent; Caption, Hint: string; ShortCut: Word; Tag, ImageIndex: integer; OnClick: TNotifyEvent; Action: TAction): TMenuItem; overload;
procedure DefineEditPopupMenuItems(PM: TPopupMenu; OnClick: TNotifyEvent);
procedure RaiseErr(ErrDesc: string);
function ChCursor(const TypCursor: TCursor): TCursor;
function WCursor: TCursor;
function NCursor: TCursor;
function SQLCursor: TCursor;
procedure SetProgressBar(PB: TProgressBar; APos, Max: integer);
function ProcMouseWheel(var WheelDelta: integer; var Key: Word): Boolean;
function NegBool(var b: Boolean): Boolean;
function NegMenuItem(Item: TMenuItem): Boolean;
function NegCheckBox(Box: TCheckBox): Boolean;
function RunFileSimple(const FileName: string): THandle;
function RunFile(const FileName, Params, DefaultDir: string; ShowCmd: integer; ShowErr: Boolean = true): THandle;
function PrintFileSimple(const FileName: string): THandle;
function PrintFile(const FileName, Params, DefaultDir: string; ShowCmd: integer): THandle;
function MoveListBox(L: TListBox; old, new: integer): Boolean;
function MoveCheckListBox(L: TCheckListBox; old, new: integer): Boolean;
function SortNum(List: TStringList; Index1, Index2: integer): integer;
function SortDate(List: TStringList; Index1, Index2: integer): integer;
function AddItemIfNotExist(List: TStrings; Text: string): Boolean;
procedure GetPrinterNames(List: TStrings);
function GetDefaultPrinterName: string;
function SetDefaultPrinter(const PrinterName: String; SendInfoMsg: Boolean): Boolean;
procedure SetupPrinterDlg(const PrinterName: String);
function GetTempDirectory: String;
function GetAppPath: string;
function GetAppDir: string;
function SetEndOfPath(const Path: string): string;
procedure UseFontFormatParams(AFont: TFont; Param: string);
function IsBitSet(const AValueToCheck, ABitIndex: integer): Boolean;
function SetBit(const AValueToAlter, ABitIndex: integer): integer;
function ResetBit(const AValueToAlter, ABitIndex: integer): integer;

Types

TArrayOfConst = array of TVarRec;

Constants

rcEditSep = 0;
rcEditUndo = 1;
rcEditCut = 2;
rcEditCopy = 3;
rcEditPaste = 4;
rcEditDelete = 5;
rcEditSelectAll = 10;
rcEditFind = 11;
rcEditFindNext = 12;
rcEditSelectFont = 13;

Description

Functions and Procedures

function WideStringToString(const ws: WideString; codePage: Word): AnsiString;
 
function StringToWideString(const s: AnsiString; codePage: Word): WideString;
 
function GetDecimalSeparator: Char;
 
function GetThousandSeparator: Char;
 
function GetDateSeparator: Char;
 
function GetThemeServices: TCustomStyleServices;
 
function GetThemeEnabled: Boolean;
 
function UpdateToDecimalSeparator(const s: string): string;
 
procedure DPI_SetFontHeight(AFont: TFont);

DPi + scale

procedure DPI_ScaleFontHeight(AFont: TFont; M, D: integer); overload;
 
procedure DPI_ScaleFontHeight(AFont: TFont; ScaleRatio: double); overload;
 
function FillStrL(const s: string; By: Char; Len: integer): string;

fill str from left

function FillStrR(const s: string; By: Char; Len: integer): string;

fill str from right

function AnsiPosEx(const Substr, s: string; From: integer = 1; CaseSensitive: Boolean = false): integer;

find substring from start position

function FindStrPart(const s, Separator: string; Sequence: byte; CaseSensitive: Boolean = false): string;

find index-th part of input string separated by separator

function RemoveStrPart(var s: string; const Separator: string; CaseSensitive: Boolean = false): string;

find first part of input string separated by separator, return it and remove from input

function FindStrFromTo(const SubstrStart, SubstrStop, s: string; CaseSensitive: Boolean = false; ExtractSubstrStart: Boolean = false): string;

find part of input string identificated by StartStr and StopStr

function ClearStr(const Substr, s: string; CaseSensitive: Boolean = false): string;

clear all substr from str

function ReplaceStr(const OldSubstr, NewSubstr, s: string; All: Boolean = true; CaseSensitive: Boolean = false): string;

replace oldSubStr by newSubStr in s

function ReplaceStrFromTo(const OldSubstrStart, OldSubstrStop, NewSubstr, s: string; ReplaceSubstrStop: Boolean = true; All: Boolean = true; CaseSensitive: Boolean = false): string;

replace oldSubStr identificated by StartStr and StopStr by newSubStr in s

procedure AddToSepList(var List: string; const StrToAdd: string; const Sep: string = ', ');

add string to separated list

function ContainWholeWord(const Substr, s: string; Separators: TSysCharSet; StartPos: integer = 0): Boolean;

check if string is wholeword = separated from other string by any chars from separators

function VarToString(PointToVar: Pointer; LengthVar: integer): string;

conversion variable to string (for saving in BLOB)

function StringToVar(PointToVar: Pointer; LengthVar: integer; s: string): Boolean;

conversion string to variable

function GetLine(const StrList: string; Index: integer): string;

get one line from string separated by EOL

function SetLine(const StrList, Line: string; Index: integer): string;

set one line in string separated by EOL

function IntToStr0(Int: integer; Len: integer): string;

conversion int to str with 0 on left side

function CreateF(const FormClass: TFormClass; var Ref; AddToFormList: Boolean = true): Boolean;

form actions

function FreeF(var Ref): Boolean;
 
function CreateShowFM(const FormClass: TFormClass; var Ref): integer;
 
procedure CreateShowF(const FormClass: TFormClass; var Ref);
 
procedure FreeAllF;
 
function GetActiveOwner: TComponent;
 
procedure FocusNextControl(Form: TForm);
 
function ShowWinHelp(Form: TForm; Command: Word; Data: integer; var CallHelp: Boolean): Boolean;
 
function ShowExtHelp(Form: TForm; Command: Word; Data: integer; var CallHelp: Boolean): Boolean;
 
function CreateMenuItem(Owner: TComponent; Caption: string; Tag: integer; OnClick: TNotifyEvent): TMenuItem; overload;

create and return new menu item with properties from params

function CreateMenuItem(Owner: TComponent; Caption, Hint: string; ShortCut: Word; Tag, ImageIndex: integer; OnClick: TNotifyEvent; Action: TAction): TMenuItem; overload;
 
procedure DefineEditPopupMenuItems(PM: TPopupMenu; OnClick: TNotifyEvent);
 
procedure RaiseErr(ErrDesc: string);

universal raising error procedure

function ChCursor(const TypCursor: TCursor): TCursor;

cursor actions

function WCursor: TCursor;
 
function NCursor: TCursor;
 
function SQLCursor: TCursor;
 
procedure SetProgressBar(PB: TProgressBar; APos, Max: integer);
 
function ProcMouseWheel(var WheelDelta: integer; var Key: Word): Boolean;

mouse actions

function NegBool(var b: Boolean): Boolean;

negate actions

function NegMenuItem(Item: TMenuItem): Boolean;
 
function NegCheckBox(Box: TCheckBox): Boolean;
 
function RunFileSimple(const FileName: string): THandle;

open document or run file

function RunFile(const FileName, Params, DefaultDir: string; ShowCmd: integer; ShowErr: Boolean = true): THandle;
 
function PrintFileSimple(const FileName: string): THandle;

open and print document

function PrintFile(const FileName, Params, DefaultDir: string; ShowCmd: integer): THandle;
 
function MoveListBox(L: TListBox; old, new: integer): Boolean;

listbox actions

function MoveCheckListBox(L: TCheckListBox; old, new: integer): Boolean;
 
function SortNum(List: TStringList; Index1, Index2: integer): integer;
 
function SortDate(List: TStringList; Index1, Index2: integer): integer;
 
function AddItemIfNotExist(List: TStrings; Text: string): Boolean;
 
procedure GetPrinterNames(List: TStrings);

printer functions

function GetDefaultPrinterName: string;
 
function SetDefaultPrinter(const PrinterName: String; SendInfoMsg: Boolean): Boolean;
 
procedure SetupPrinterDlg(const PrinterName: String);
 
function GetTempDirectory: String;

Get temporary directory

function GetAppPath: string;

return path of exe program

function GetAppDir: string;

return path of exe program

function SetEndOfPath(const Path: string): string;

set end of the Path with backslash

procedure UseFontFormatParams(AFont: TFont; Param: string);

set font style, color and size according Param string: N=normal B=bold I=italic U=underline Red, Blue = color $00xxxxxx = color 8, 9, 10, 12, 14 ... = size

function IsBitSet(const AValueToCheck, ABitIndex: integer): Boolean;
 
function SetBit(const AValueToAlter, ABitIndex: integer): integer;
 
function ResetBit(const AValueToAlter, ABitIndex: integer): integer;
 

Types

TArrayOfConst = array of TVarRec;
 

Constants

rcEditSep = 0;
 
rcEditUndo = 1;
 
rcEditCut = 2;
 
rcEditCopy = 3;
 
rcEditPaste = 4;
 
rcEditDelete = 5;
 
rcEditSelectAll = 10;
 
rcEditFind = 11;
 
rcEditFindNext = 12;
 
rcEditSelectFont = 13;
 

Author

Created

Nov 2005

Last Modified

Apr 2017


Generated by PasDoc 0.13.0 on 2017-06-17 14:57:07