TWPLocalLoadObjectStrings Type
This procedure is executed when a certain object has to be initialized.

Unit
WPLocalize

Declaration

TWPLocalLoadObjectStrings = procedure(
     const Control : TObject;
     const Entries : TStringList;
       var Done, NoDefault : Boolean);

Description
Properties with the name Hint or Caption are automatically saved and loaded. To add support for special properties, such as the Items property you can code like this:
var
  previous_WPLocalSaveObjectStrings : TWPLocalSaveObjectStrings;
  previous_WPLocalLoadObjectStrings : TWPLocalLoadObjectStrings;

procedure SaveHintAndCaption(
     const Control : TObject;
     const Entries : TStringList;
       var Done, NoDefault : Boolean);
begin
  if assigned(previous_WPLocalSaveObjectStrings) then
     previous_WPLocalSaveObjectStrings(Control,Entries,Done,NoDefault);
  if not Done then
  begin
     if Control is TLabel then
     begin
        Entries.Add('CAPTION=' + TLabel(Control).Caption);
        Entries.Add('HINT=' + TLabel(Control).Hint);
        Done := TRUE;
        NoDefault := TRUE;
     end;
  end;
end;

procedure LoadHintAndCaption(
     const Control : TObject;
     const Entries : TStringList;
       var Done, NoDefault : Boolean);
var i : Integer;
begin
  if assigned(previous_WPLocalLoadObjectStrings) then
     previous_WPLocalLoadObjectStrings(Control,Entries,Done,NoDefault);
  if not Done then
  begin
     if Control is TLabel then
     begin
       // Check if we have an entry and if we do - load the text        
	   i := Entries.IndexOfName('CAPTION');
       if i>=0 then TLabel(Control).Caption := Entries.Values['CAPTION'];
       i := Entries.IndexOfName('HINT');
       if i>=0 then TLabel(Control).Hint := Entries.Values['HINT'];
       Done := TRUE;
       NoDefault := TRUE;
     end;
  end;
end;

initialization
  previous_WPLocalSaveObjectStrings := WPLocalSaveObjectStrings;
  previous_WPLocalLoadObjectStrings := WPLocalLoadObjectStrings;

  WPProgramLoadPath := ExtractFilePath(ParamStr(1));
  WPProgramSavePath := WPProgramLoadPath;

finalization

  WPLocalSaveObjectStrings := previous_WPLocalSaveObjectStrings;
  WPLocalSaveObjectStrings := Addr(SaveHintAndCaption);

  WPLocalLoadObjectStrings := previous_WPLocalLoadObjectStrings;
  WPLocalLoadObjectStrings := Addr(LoadHintAndCaption);
end.


Copyright (C) by WPCUBED GmbH - Munich
http://www.wpcubed.com