Changeset 242 for Docking/CoolDocking


Ignore:
Timestamp:
May 11, 2011, 3:47:47 PM (14 years ago)
Author:
george
Message:
  • Added: Save/Load layout to string. Useful for store layout in registry instead of file.
Location:
Docking/CoolDocking
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCDClient.pas

    r198 r242  
    110110      UseDockManager := True;
    111111      DockManager := TCDManagerRegions.Create(TWinControl(AOwner));
     112      //FormStyle := fsStayOnTop;
    112113    end;
    113114  end;
  • Docking/CoolDocking/UCDLayout.pas

    r218 r242  
    6060    procedure LoadFromFile(FileName: string);
    6161    procedure SaveToFile(FileName: string);
     62    procedure LoadFromString(Value: string);
     63    function SaveToString: string;
    6264    procedure PopulateStringList(List: TStrings);
    6365    function FindByName(Name: string): TCDLayout;
     
    198200    Stream.Size := 0;
    199201    SaveToStream(Stream);
     202  finally
     203    Stream.Free;
     204  end;
     205end;
     206
     207procedure TCDLayoutList.LoadFromString(Value: string);
     208var
     209  Stream: TMemoryStream;
     210begin
     211  if Length(Value) > 0 then
     212  try
     213    Stream := TMemoryStream.Create;
     214    Stream.WriteBuffer(Value[1], Length(Value));
     215    Stream.Position := 0;
     216    LoadFromStream(Stream);
     217  finally
     218    Stream.Free;
     219  end;
     220end;
     221
     222function TCDLayoutList.SaveToString: string;
     223var
     224  Stream: TMemoryStream;
     225begin
     226  Result := '';
     227  try
     228    Stream := TMemoryStream.Create;
     229    Stream.Size := 0;
     230    SaveToStream(Stream);
     231    if Stream.Size > 0 then begin
     232      SetLength(Result, Stream.Size);
     233      Stream.Position := 0;
     234      Stream.ReadBuffer(Result[1], Stream.Size);
     235    end;
    200236  finally
    201237    Stream.Free;
Note: See TracChangeset for help on using the changeset viewer.