This unit contains general classes and functions.

Here is the brief description of what is implemented in dcgen.

=====================================================================
 Classes
=====================================================================

[TFDesigner]

  If you'll look into dsgnintf.pas you will note that TFormDesigner is declared
  as class with only abstract methods. And some functions (like
  GetComponentEditor and GetComponentProperties) require the instance of
  TFormDesigner. So the only way for you to use these functions is to override
  TFormDesigner and implement all its methods. Or you can use TFDesigner. This
  class provides the basic functionality of TFormDesigner used in VCL functions.
  Some of methods are empty - the only purpose of their existance is to avoid
  'Abstract Error'.
  Look Example1 for example of using of TFDesigner.


[TAxControlCollection]

  With TAxControlCollection retrieving the list of registered ActiveX controls
  is a piece of cake. Just create it and you will get full info about all OLE
  controls and libraries that are installed.
  Example2 shows the usage of this class.


[TIntStack]

  This simple class provide stack interface for integer numbers (and all types
  that can be casted to integer like TObject).


[TFileNameEdit]

  Use TFileNameEdit when you has the property that contains the name of some
  file.


[THistoryStringEdit]

  This property editor maintains the history list of entered values. Using of
  THistoryStringEdit together with TDCPropEditor allows you easily create
  combos that remember entered values (e.g. Search|Find|Text to find).
  History is stored in registry. If you need to specify the registry key
  override GetRegName method. If you want to save history in some other place
  override SaveHistory and LoadHistory.
  Good example of how to use THistoryStringEdit you can find in Instant Report.

[TPropNameEditor]

  This property editor is used when you need to select one of published
  properties of object. Look to TDCPropEditor PropName property in
  Object Inspector to see what does it look like.

[TFontSizePropEdit]

  This property editor improves standard Font property editor so now you
  can select the size of the font from the list of values just like in Microsoft
  Word.


=====================================================================
 Property Assigning
=====================================================================

procedure SetEnabledControls(Const Ctrls:Array of TObject; Enabled:boolean);

  Use this procedure to control enabled state of several controls simultaneously


procedure UpdateLabelsEnabled(F:TCustomForm);

  Call this procedure to update labels enabled state using the following rule:
  Label is enabled if control to which label is linked (FocusControl property)
  is enabled. UpdateLabelsEnabled iterates through all labels of the given form.


procedure AssignAllProps(Source,Dest:TObject);

  Assigns all published properties existing in both objects from Source object
  to Dest object.


procedure SetFlatProp(const Ctrls:Array of TObject; V:Boolean);

  Call SetFlatProp to set Flat property of specified array of objects.
  If Object hasn't Flat property then it won't be modified.
  This procedure is used when you need to make a form with speedbuttons compatible with
  D2, cause in D2 TSpeedButton doesn't have Flat property.


procedure AssignProps(Source, Dest : TObject; PropNames : array of string);

 Assigns published properties from the source object to the destination object.

 Specify in PropNames the names of property that will be copied.

 Note: If Source = Dest or Source = nil or Dest = nil then nothing will happen.


procedure AssignPropsEx(Source,Dest:TObject; Const Propnames:String);

 If you need to copy property values from one object to another then
 call AssignPropsEx passing property names delimited by comma in PropNames parameter.
 For example AssignPropsEx(Button1, Button2, 'Visible,Enabled,Caption').
 PropNames isn't case-sensitive. If property you specify doesn't exist in both
 Source and Dest then it is ignored.


procedure SetPropValues(const Ctrls:Array of TObject; const PropName:String; Val:Variant);

  Call this procedure to set property value to several objects simultaneously.
  Now you don't need to write smth like
    Button1.Enabled := true;
    ...                          // 8 lines skipped
    Button10.Enabled := true;

  Just use SetPropValues([Button1, ..., Button10], 'Enabled', true);


=====================================================================
 List handling
=====================================================================

function EqualList(l1, l2 : TList) : boolean;

  Compares two lists and returns True if they are equal
  (Lists are equal when they have equal number of items and
   all items pointers are equal)


function ListsInterSect(l1, l2 : TList) : boolean;

  Returns True if two lists intersect


procedure FreeList(var list : TList);

  Call this procedure to free all items of the given list and the list itself.
  Note that L will be nil after FreeList.


procedure CompListToList(clist : TComponentList; list : TList);

 Converts component list to ordinary list
 (all items from source component list are added to the destination list)


procedure ListToCompList(list : TList; clist : TComponentList);

  Converts list to component list


procedure CopyList(FromList,ToList : TList);

  Call this procedure to copy all items from one list to another


=====================================================================
 Registry
=====================================================================

procedure WriteWinPosToReg(C:TWinControl;Const S:String);
procedure ReadWinPosFromReg(C:TWinControl;Const S:String);

  Writes and reads the window position and state to registry. Use these
  functions to store the placement of controls or forms.


function  ReadFromRegistry(Const VarName:String;DefaultValue:Variant):Variant;
procedure WriteToRegistry(Const VarName:String;VarValue:Variant);

  With these functions you don't need to keep in memory dozen of TRegistry
  Read... and Write... methods. ReadFromRegistry and WriteToRegistry will use
  appropriate registry format automatically.

  Note that you need to set ApplicationName constant to specify the root key in
  Registry.


procedure ReadStringsFromRegistry(Const VarName:String;S:TStrings);
procedure WriteStringsToRegistry(Const VarName:String;S:TStrings);

  Another pair of functions that make storing StringList in Registry a snap.


=====================================================================
 Internet
=====================================================================

procedure JumpToURL(const s : string);

  JumpToURL makes it easy to open HTML or create an e-mail.
  This examples show how to use JumpToURL procedure

  // this line will bring up our home page
  JumpToURL('http://www.brama.com/dream-co');

  // this line will send us a message
  JumpToURL('mailto: kurinn@gu.kiev.ua');


=====================================================================
 Strings handling
=====================================================================

function  ChangeCharTo(FromChar,ToChar:Char; Const S:String):String;

  Scans for all occurences of FromChar in string S and replaces them with ToChar.
  Result is changed string.

  Example:
    ChangeCharTo('a','b','aaa')='bbb';


function RemoveCharSet(Const A : TCharSet; Const S : String) : String;

  Deletes all occurences of chars (members of set A) from string S


function CloneChar(C:Char;Len:Integer):String;

  Returns string of required lengths filled with the same character.


function PosEx(const SubStr, S : AnsiString; FromChar : Integer) : Integer;

  Powerful procedure for searching substring in a string. Same as usual pos
  but can search not only from beginning of the string.

  Pos('a','aa') = PosEx('a','aa',1)


function BackPosEx(const SubStr, S : AnsiString; FromChar : Integer) : Integer;

  Same as PosEx but searches backwards


=====================================================================
 Menus
=====================================================================

function GetControlPopupMenu(c : TControl) : TPopupMenu;

  Returns popup menu which will be shown when user
  clicks right mouse button on the given control.


procedure CopyPopupMenu(SourceMenu,TargetMenu:TPopupMenu);

  Copies all menu items from SourceMenu to TargetMenu


function  GetRealMenuIndex(menuitem : TMenuItem) : integer;

 MenuItem has property MenuIndex. But when there are some invisible menu items this
 property can't be used with Win32 functions because they work with real index of menu item.
 So if you need to get it just call GetRealMenuIndex.


=====================================================================
 Graphics
=====================================================================

function  GetRGBColor(Value: TColor): Integer;

  GetRGBColor converts given Delphi color to RGB representation used in Win32 API


procedure DrawGrayText(DC : THandle; R : TRect; const Text : string; flags : integer);

 DrawGrayText is used to draw 3D-like disabled text. It calls DrawText function and
 if you need to pass some specific flags for drawing (e.g. alignment flags) pass it in
 flags parameter.


procedure DrawBeveledRect(DC : THandle; R : TRect; color1, color2 : TColor);

 Use DrawBeveledRect to make some rect appear raised or sunken.


=====================================================================
 Miscellaneous
=====================================================================

procedure FreeObject(var O);

  Call this procedure to free object and assign nil to the pointer.

  FreeObject(Object);  is equal to  Object.Free;
                                    Object := nil;


procedure IterateProps(Instance:TPersistent;TypeKinds: TTypeKinds;CallBack:TPropCallBack;
          AOnlyStored:Boolean);

  Calls CallBack procedure for each published property of given object.
  Property types can be limited using TypeKinds parameter.


procedure StringsToProc(S:TStrings; Proc: TGetStrProc);

  StringsToProc will call procedure Proc for every string in strings object.


Function  GetClassUnit(O:TObject):String;

  Returns name of unit where object O was declared.


procedure CallPropertyEdit(C:TPersistent;Const Propname:String);

 Creates property editor for object C and property PropName and calls it's Edit
 method.

 Example:
    This example shows how to use function CallPropertyEdit

    Var
      S : TStringList;
    begin
      // create string list
      S := TStringList.Create;
      try
        // call property editor for strings property
        CallPropertyEdit(S, 'Strings');
      finally
        //  destroy string list
        S.Free;
      end;
    end;


function KeysToShift:TShiftState;

  Returns the state of currently pressed keys (Shift,Alt,Ctrl) in TShiftState
  record


procedure RegisterNotifier(C:TObject);

  Call this function to register object in the "message system". After object is registered
  in the message system, it will receive different messages sent by our controls
  (package loader, form designer, object inspector, etc.). See message consts CM_*


procedure UnregisterNotifier(C:TObject);

  Unregisters previously registered object in our message system

procedure BroadCastToNotifiers(Self:TObject;Msg: Cardinal; WParam, LParam: Longint);

  Call this function to broadcast message Msg with params WParam,LParam to notifiers
  (objects registered in our message system by calling RegisterNotifier procedure)


function DelphiRunning : boolean;

  Checks is Delphi or CPB is running or not. Useful for creating
  trial versions of components


procedure SafeRegisterClass(AClass: TPersistentClass);

  Calls RegisterClass procedure only if class wasn't registered previously


function CompiledWithPackages:boolean;

  This function returns True if application was compiled with packages


function FormIsActive(F:TCustomForm):boolean;

  Returns true if particular form is "active"
  Form is "active" when it's focused or if it the topmost form
  after the main form


function GetDesigner(c : TPersistent) : TFormDesigner;

  GetDesigner will find the parent form and return Form Designer if any


procedure RenameToBak(Const Path:String);

  Renames file with name - Path to "~" name

  For example
    RenameToBak('aa.pas');
  renames file aa.pas to aa.~pa
  If file aa.~pa existed before rename it will be deleted.


Function  FileBakName(Const Path:String):String;

  Returns correct "~" name for the file
  Example:
     FileBakName('a.pas')='a.~pa';



