{***************************************************************************}
{ TMS IntraWeb Component Pack Pro                                           }
{ for Delphi & C++Builder                                                   }
{                                                                           }
{ written by TMS Software                                                   }
{            copyright © 2002 - 2014                                        }
{            Email : info@tmssoftware.com                                   }
{            Web : http://www.tmssoftware.com                               }
{                                                                           }
{ The source code is given as is. The author is not responsible             }
{ for any possible damage done due to the use of this code.                 }
{ The component can be freely used in any application. The complete         }
{ source code remains property of the author and may not be distributed,    }
{ published, given or sold in any form as such. No parts of the source      }
{ code can be included in any other component or application without        }
{ written authorization of the author.                                      }
{***************************************************************************}

{$I TMSDEFS.INC}

{$R tmsiwjquery.RES}

unit IWTMSBase;

interface
uses
  IWControl, IWColor, IWTypes, Graphics
  , IWServer, DB, IWCompEdit, Classes, IWForm, IWRegion, Types
  , IWRenderContext, TypInfo
  {$IFDEF TMSIW121}
  //IWBrowserBase,
  , IW.Browser.Browser, IW.Browser.InternetExplorer, IW.Browser.Chrome,
  IW.Browser.Safari, IW.Browser.Firefox, IW.Browser.Android,
  IW.Browser.SafariMobile, IW.Browser.Other, IW.Browser.SearchEngine,
  IW.Browser.Webkit, IWServerInternalFiles
  {$ENDIF}
  {$IFDEF DELPHIXE2_LVL}
  , System.UITypes
  {$ENDIF}
  {$IFDEF TMSIW14}
  , IWApplication, IW.CacheStream
  {$ENDIF}
  ;

type
  TIWImageType = (imgPNG, imgJPEG, imgGIF, imgBMP);
  TTIWGradientDirection = (gdHorizontal, gdVertical);

  {$IFDEF TMSIW11}
  TIWComponent40Context = TIWCompContext;
  TIWBaseHTMLComponentContext = TIWCompContext;
  TIWBaseComponentContext = TIWCompContext;
  {$ELSE}
  TIWBaseComponentContext = TIWBaseHTMLComponentContext;
  {$ENDIF}

  TIWAppCache = class
  public
    // Save AGraphic to cache file. Will preferentially use default image format if GIF/JPG
    class function GraphicToCacheFile(AGraphic: TGraphic; const ImgType: TIWImageType): string;
    class function StreamToCacheFile(AStream: TMemoryStream; const ImgType: TIWImageType): string;
  end;

  TTIWTMSCustomEdit = class(TIWCustomEdit)
  public
    constructor Create(AOwner: TComponent); override;
    function GetParentForm(Control: TObject): TIWForm;
  end;

  TTIWTMSDataLink = class(TDataLink)
  private
    FIWControl: TIWCustomEdit;
  protected
    procedure DataSetScrolled(Distance: Integer); override;
    procedure RecordChanged(Field: TField); override;
  public
    constructor Create(AControl: TIWCustomEdit);
  end;

  TTIWTMSControlDataLink = class(TDataLink)
  private
    FIWControl: TIWControl;
  protected
    procedure DataSetScrolled(Distance: Integer); override;
    procedure RecordChanged(Field: TField); override;
  public
    constructor Create(AControl: TIWControl);
  end;

  //IW121
  TTMSBrowser=(
     brUnknown
     , brNetscape7
     , brIE, brGecko, brOpera, brSafari, brChrome
     , brIE4, brNetscape6, brNetscape4, brOther, brHTML32Test
     , brWMLTest, brXHTMLMPTest, brWAP
   );

  procedure TMSAddInternalFile(FileID, FileName: string);
  function IsBrowserIe(AContext: TIWBaseComponentContext): boolean; overload;
  function IsBrowserIe(AContext: TIWPageContext40): boolean; overload;

  function IsBrowserIe10(AContext: TIWBaseComponentContext): boolean; overload;
  function IsBrowserIe10(AContext: TIWPageContext40): boolean; overload;

  function IsBrowserIe7(AContext: TIWBaseComponentContext): boolean; overload;
  function IsBrowserIe7(AContext: TIWPageContext40): boolean; overload;

  function GetTMSBrowser(AContext: TIWBaseComponentContext): TTMSBrowser; overload;
  function GetTMSBrowser(AContext: TIWPageContext40): TTMSBrowser; overload;
  //END IW121

  function GetResourceText(ResName:string): string;
  function GetCacheURL(): string;
  function GetCacheDir(): string;
  function GetNewCacheFile(APrefix: string; AUserCache: Boolean): string;
  function GetControlHTML(Control: TIWCustomControl; AContext: TIWBaseComponentContext): string;

  function GetProgramFiles: string;
  {$IFNDEF DELPHI6_LVL}
  function ForceDirectories(Dir: string): Boolean;
  {$ENDIF}

  {$IFNDEF DELPHI6_LVL}
  function StrToBool(s: string): boolean;
  {$ENDIF}

  function PrepAsyncStr(s: string): string;

  procedure DrawGradient(Canvas: TCanvas; FromColor, ToColor: TIWColor; Steps: Integer; r:TRect; Direction: Boolean);

  function GradientStyle(Color,Color1,Color2,NoColor: TIWColor; Direction: TTIWGradientDirection; AContext: TIWBaseComponentContext; Attribute: boolean): string;

  procedure Split(const Delimiter: Char; Input: string; const Strings: TStrings);


implementation

uses
  IWGlobal, SysUtils, IWHTMLTag, ShlObj, ActiveX , Windows, IWServerControllerBase,
  TMSIWStrings, TMSIWSystem
  {$IFDEF FREEWARE}
  {$IFDEF TMSIW51}
  , IWKlooch
  {$ELSE}
  {$IFNDEF DELPHI7_LVL}
  , IWKlooch
  {$ENDIF}
  {$ENDIF}
  {$ENDIF}

  {$IFDEF TMSIW14}
 , IWImageUtils //required for IWAppCache
  {$ENDIF}
  ;

procedure Split (const Delimiter: Char; Input: string; const Strings: TStrings);
begin
  Assert(Assigned(Strings));
  Strings.Clear;

  while pos(delimiter, input) > 0 do
  begin
    strings.Add(copy(input, 1, pos(delimiter, input) - 1));
    system.delete(input, 1, pos(delimiter, input));
  end;

  Strings.Add(input);
end;


{$IFDEF TMSIW121}
function Get121Browser(xbrowser: Tbrowser):TTmsBrowser;
begin
  if xBrowser is TInternetExplorer then
    result := BrIE
  else if xBrowser is TChrome then
    result := BrChrome
  else if xBrowser is TFireFox then
    result := BrGecko
//  else if xBrowser is TSafari then
//  else if (xBrowser is TSafari) or (xBrowser is TSafariMobile) then
  else if (xBrowser is TWebKit) then
    result := BrSafari
  else
    result:=brOther;
end;
{$ELSE}
function GetPre121Browser(xBrowser:integer):TTmsBrowser;
begin
  case xBrowser of
    0: result := brunknown;
    1: result := BrNetscape7;
    2: result := BrIE;
    3: result := brgecko;
    4: result := brOpera;
    5: result := brsafari;
    6: result := brchrome;
    7: result := brIE4;
    8: result := brNetscape6;
    9: result := brNetScape4;
    10: result := brHTML32Test;
    11: result := brWMLTest;
    12: result := brXHTMLMPTest;
    13: result := brWap;
  else
    result:=brunknown;
  end;
end;
{$ENDIF}

function GetTMSBrowser(AContext: TIWBaseComponentContext):TTMSBrowser;
begin
  {$IFDEF TMSIW121}
  result := Get121Browser(aContext.webApplication.Browser);
  {$ELSE}
  result := GetPre121Browser(integer(AContext.webapplication.browser));
  {$ENDIF}
end;

function GetTMSBrowser(AContext: TIWPageContext40):TTMSBrowser;overload;
begin
  {$IFDEF TMSIW121}
  result := Get121Browser(aContext.webApplication.Browser);
  {$ELSE}
  result := GetPre121Browser(integer(AContext.webapplication.Browser));
  {$ENDIF}
end;

function IsBrowserIe(AContext: TIWBaseComponentContext):boolean;
begin
  result := GetTmsBrowser(aContext) = BrIe;
end;

function IsBrowserIe(AContext: TIWPageContext40):boolean;
begin
  result := GetTmsBrowser(aContext) = BrIe;
end;

function IsBrowserIe10(AContext: TIWBaseComponentContext):boolean;
begin
  result := false;
  if GetTmsBrowser(aContext) = BrIe then
  begin
    {$IFDEF TMSIW121}
    result := AContext.WebApplication.Browser.Version >= 10;
    {$ELSE}
//    result := AContext.WebApplication.BrowserSubType = brsIE10;
    result := GetEnumName(TypeInfo(TIWBrowserSubtype), Integer(AContext.WebApplication.BrowserSubType)) = 'brsIE10';
    {$ENDIF}
  end;
end;

function IsBrowserIe10(AContext: TIWPageContext40):boolean;
begin
  result := false;
  if GetTmsBrowser(aContext) = BrIe then
  begin
    {$IFDEF TMSIW121}
    result := AContext.WebApplication.Browser.Version >= 10;
    {$ELSE}
//    result := AContext.WebApplication.BrowserSubType = brsIE10;
    result := GetEnumName(TypeInfo(TIWBrowserSubtype), Integer(AContext.WebApplication.BrowserSubType)) = 'brsIE10';
    {$ENDIF}
  end;
end;

function IsBrowserIe7(AContext: TIWBaseComponentContext):boolean;
begin
  result := false;
  if GetTmsBrowser(aContext) = BrIe then
  begin
    {$IFDEF TMSIW121}
    result := AContext.WebApplication.Browser.Version >= 7;
    {$ELSE}
//    result := AContext.WebApplication.BrowserSubType = brsIE10;
    result := GetEnumName(TypeInfo(TIWBrowserSubtype), Integer(AContext.WebApplication.BrowserSubType)) = 'brsIE7';
    {$ENDIF}
  end;
end;

function IsBrowserIe7(AContext: TIWPageContext40):boolean;
begin
  result := false;
  if GetTmsBrowser(aContext) = BrIe then
  begin
    {$IFDEF TMSIW121}
    result := AContext.WebApplication.Browser.Version >= 7;
    {$ELSE}
//    result := AContext.WebApplication.BrowserSubType = brsIE10;
    result := GetEnumName(TypeInfo(TIWBrowserSubtype), Integer(AContext.WebApplication.BrowserSubType)) = 'brsIE7';
    {$ENDIF}
  end;
end;

procedure TMSAddInternalFile(FileID, FileName: string);
begin
  {$IFDEF TMSIW121}
  gInternalFiles.add(FileID, FileName);
  {$ELSE}
  TIWServer.AddInternalFile(FileID, FileName);
  {$ENDIF}
end;

procedure DrawGradient(Canvas: TCanvas; FromColor, ToColor: TIWColor; Steps: Integer; r:TRect; Direction: Boolean);
var
  diffr,startr,endr: Integer;
  diffg,startg,endg: Integer;
  diffb,startb,endb: Integer;
  iend: Integer;
  rstepr,rstepg,rstepb,rstepw: Real;
  i,stepw: Word;

begin
  if Steps = 0 then
    Steps := 1;

  FromColor := ColorToRGB(FromColor);
  ToColor := ColorToRGB(ToColor);

  startr := (FromColor and $0000FF);
  startg := (FromColor and $00FF00) shr 8;
  startb := (FromColor and $FF0000) shr 16;
  endr := (ToColor and $0000FF);
  endg := (ToColor and $00FF00) shr 8;
  endb := (ToColor and $FF0000) shr 16;

  diffr := endr - startr;
  diffg := endg - startg;
  diffb := endb - startb;

  rstepr := diffr / steps;
  rstepg := diffg / steps;
  rstepb := diffb / steps;

  if Direction then
    rstepw := (R.Right - R.Left) / Steps
  else
    rstepw := (R.Bottom - R.Top) / Steps;

  with Canvas do
  begin
    for i := 0 to Steps - 1 do
    begin
      endr := startr + Round(rstepr*i);
      endg := startg + Round(rstepg*i);
      endb := startb + Round(rstepb*i);
      stepw := Round(i*rstepw);
      Pen.Color := endr + (endg shl 8) + (endb shl 16);
      Brush.Color := Pen.Color;
      if Direction then
      begin
        iend := R.Left + stepw + Trunc(rstepw) + 1;
        if iend > R.Right then
          iend := R.Right;
        Rectangle(R.Left + stepw,R.Top,iend,R.Bottom)
      end
      else
      begin
        iend := R.Top + stepw + Trunc(rstepw)+1;
        if iend > r.Bottom then
          iend := r.Bottom;
        Rectangle(R.Left, R.Top+stepw,R.Right,iend);
      end;
    end;
  end;
end;

{$IFNDEF DELPHI6_LVL}
function StrToBool(s: string): boolean;
begin
  Result :=  Uppercase(s) = 'TRUE';
end;
{$ENDIF}

function GradientStyle(Color,Color1,Color2,NoColor: TIWColor; Direction: TTIWGradientDirection; AContext: TIWBaseComponentContext; Attribute: boolean):string;
var
//IW121
//  FBrowserType: TIWBrowser;
  FBrowserType: TTMSBrowser;
begin

//IW121
//  FBrowserType := AContext.WebApplication.Browser;
  FBrowserType := GetTMSBrowser(AContext);

{$IFDEF TMSIW10}
  if (Color1 <> NoColor) and (Color2 <> NoColor) and (FBrowserType in [brIE, brGecko, brChrome, brSafari]) then
{$ELSE}
  if (Color1 <> NoColor) and (Color2 <> NoColor) and (FBrowserType in [brIE, brSafari]) then
{$ENDIF}
  begin
    if FBrowserType = brIE then
    begin

      if not IsBrowserIe10(AContext) then
      begin
        Result := 'progid:DXImageTransform.Microsoft.Gradient(GradientType=' +
          IntToStr(1 - Integer(Direction)) + ', StartColorStr=' + ColorToRGBString(Color1) + ', EndColorStr=' + ColorToRGBString(Color2) + ')';

        if Attribute then
          Result := 'FILTER: ' + Result + ';';
      end
      else
      begin
        if Direction = gdHorizontal then
          Result := '-ms-linear-gradient(left, ' + ColorToRGBString(Color1) + ', ' + ColorToRGBString(Color2) + ')'
        else
          Result := '-ms-linear-gradient(top, ' + ColorToRGBString(Color1) + ', ' + ColorToRGBString(Color2) + ')';

        if Attribute then
          Result := 'background-image: ' + Result + ';';
      end;
    end
{$IFDEF TMSIW10}
    else if FBrowserType = brGecko then
    begin
      if Direction = gdHorizontal then
      	Result := '-moz-linear-gradient(left, ' + ColorToRGBString(Color1) + ', ' + ColorToRGBString(Color2) + ')'
      else
      	Result := '-moz-linear-gradient(top, ' + ColorToRGBString(Color1) + ', ' + ColorToRGBString(Color2) + ')';

      if Attribute then
        Result := 'background-image: ' + Result + ';';
    end
{$ENDIF}
{$IFDEF TMSIW10}
    else if (FBrowserType in [brChrome, brSafari]) then
{$ELSE}
    else if (FBrowserType in [brSafari]) then
{$ENDIF}
    begin
      if Direction = gdHorizontal then
        Result := '-webkit-gradient(linear, left top, right top, from(' + ColorToRGBString(Color1) + '), to(' + ColorToRGBString(Color2) + '))'
      else
        Result := '-webkit-gradient(linear, left top, left bottom, from(' + ColorToRGBString(Color1) + '), to(' + ColorToRGBString(Color2) + '))';

      if Attribute then
        Result := 'background-image: ' + Result + ';';
    end;
  end
  else
  begin
    if Color1 <> NoColor then
      Result := ColorToRGBString(Color1)
    else if Color <> NoColor then
      Result := ColorToRGBString(Color);

    if Attribute then
      Result := 'background-color: ' + Result + ';';
  end;
end;

function PrepAsyncStr(s: string): string;
begin
  s := StringReplace(s, '"', '\"', [rfReplaceAll]);
  s := StringReplace(s, #13, ' ', [rfReplaceAll]);
  s := StringReplace(s, #10, ' ', [rfReplaceAll]);
  s := StringReplace(s, #$D, ' ', [rfReplaceAll]);
  Result := StringReplace(s, #$A, ' ', [rfReplaceAll]);
end;


function GetControlHTML(Control: TIWCustomControl;
  AContext: TIWBaseComponentContext): string;
var
  it: TIWHTMLTag;
begin
  // !!!!!!!!!!!!!! IMPORTANT NOTICE !!!!!!!!!!!!!!!!!!
  //
  // If you encounter a compilation problem here,
  // make sure that you followed the installation steps
  // in INSTALL.TXT, in particular, that you're using the
  // correct TMSDEFS.INC file
  //
  // !!!!!!!!!!!!!! IMPORTANT NOTICE !!!!!!!!!!!!!!!!!!

  it := Control.RenderHTML(AContext);
  Result := it.Render;
  it.Free;
end;

function GetResourceText(ResName: string): string;
var
  p: ansichar;
  RS: TResourceStream;
  i: Integer;
begin
  RS := TResourceStream.Create(HInstance, ResName, RT_RCDATA);

  Result := '';

  for i := 1 to RS.Size do
  begin
    RS.Read(p,1);
    Result := Result + string(p);
  end;

  RS.Free;
end;


procedure FreePidl( pidl: PItemIDList );
var
  Allocator: IMalloc;
begin
  if Succeeded(SHGetMalloc(allocator)) then
  begin
    Allocator.Free(pidl);
  end;
end;

function GetProgramFiles: string;
const
  CSIDL_PROGRAM_FILES = $0026;
var
  pidl: PItemIDList;
  Path: array [0..MAX_PATH-1] of char;
begin
  Result := '';
  if Succeeded(SHGetSpecialFolderLocation(0, CSIDL_PROGRAM_FILES, pidl)) then
  begin
    if SHGetPathFromIDList(pidl, Path) then
      Result := Path;
    FreePidl(pidl);
  end;
end;

{$IFNDEF DELPHI6_LVL}
function DirectoryExists(const Name: string): Boolean;
var
  Code: Integer;
begin
  Code := GetFileAttributes(PChar(Name));
  Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
end;

function ForceDirectories(Dir: string): Boolean;
begin
  Result := True;
  if Length(Dir) = 0 then
    raise Exception.Create('Cannot create directory');

  if Dir[length(Dir)] = '\' then
    Delete(Dir,length(Dir),1);

  if (Length(Dir) < 3) or DirectoryExists(Dir)
    or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
  Result := ForceDirectories(ExtractFilePath(Dir)) and CreateDir(Dir);
end;
{$ENDIF}

{ TTIWTMSDataLink }

constructor TTIWTMSDataLink.Create(AControl: TIWCustomEdit);
begin
  inherited Create;
  FIWControl := AControl;
end;

procedure TTIWTMSDataLink.DataSetScrolled(Distance: Integer);
begin
  inherited;
  if Assigned(FIWControl) then
    FIWControl.Invalidate;
end;

procedure TTIWTMSDataLink.RecordChanged(Field: TField);
begin
  inherited;
  if Assigned(FIWControl) then
    FIWControl.Invalidate;
end;

{ TTIWTMSControlDataLink }

constructor TTIWTMSControlDataLink.Create(AControl: TIWControl);
begin
  inherited Create;
  FIWControl := AControl;
end;

procedure TTIWTMSControlDataLink.DataSetScrolled(Distance: Integer);
begin
  inherited;
  if Assigned(FIWControl) then
    FIWControl.Invalidate;
end;

procedure TTIWTMSControlDataLink.RecordChanged(Field: TField);
begin
  inherited;
  if Assigned(FIWControl) then
    FIWControl.Invalidate;
end;


{ TTIWTMSCustomEdit }
constructor TTIWTMSCustomEdit.Create(AOwner: TComponent);
//var
//  C: TRttiContext;
//  CompType: TRttiInstanceType;
//  CompProp: TRttiProperty;
begin
  inherited;
  //New property from IW 14.0.19
  //Set to false to avoid double or unwanted control border
  //{$IFDEF TMSIW14019}

  if IsPublishedProp(Self.StyleRenderOptions,'RenderBorder') then
      SetOrdProp(Self.StyleRenderOptions,'RenderBorder',integer(false))

//  c := TRttiContext.Create;
//
//  CompType :=  c.GetType(StyleRenderOptions.ClassInfo) as TRttiInstanceType;
//
//  CompProp := CompType.GetProperty('RenderBorder');
//  if Assigned(CompProp) then
//  begin
//    //StyleRenderOptions.RenderBorder := False;
//    CompProp.SetValue(StyleRenderOptions, False);
//  end;
//
//  c.Free;
  //{$ENDIF}
end;

function TTIWTMSCustomEdit.GetParentForm(Control: TObject): TIWForm;
begin
  Result := nil;
  if Assigned(Control) then
    if Control is TIWForm then
    begin
      Result := Control as TIWForm;
      Exit;
    end
    else
    begin
      if Control is TIWCustomControl then
      begin
        if Assigned((Control as TIWCustomControl).Parent) then
           Result := GetParentForm((Control as TIWCustomControl).Parent);
      end;
      if Control is TIWCustomRegion then
      begin
        if Assigned((Control as TIWCustomRegion).Parent) then
           Result := GetParentForm((Control as TIWCustomRegion).Parent);
      end;
    end;
end;

function GetCacheDir(): string;
begin
{$IFDEF TMSIW14}
{$ELSE}
  Result := GServerController.UserCacheURL;
{$ENDIF}
end;

function GetCacheURL(): string;
begin
{$IFDEF TMSIW14}
{$ELSE}
  Result := GServerController.CacheURL;
{$ENDIF}
end;

function GetNewCacheFile(APrefix: string; AUserCache: Boolean): string;
{$IFDEF TMSIW14}
begin
{$ELSE}
begin
  Result := TIWServerControllerBase.NewCacheFile(APrefix,AUserCache);
{$ENDIF}
end;

{ TIWAppCache }

{$IFDEF TMSIW14}
class function TIWAppCache.GraphicToCacheFile(AGraphic: TGraphic;
  const ImgType: TIWImageType): string;
var
  xCacheStream: TCacheStream;
  xContentType: string;
  ASession: TIWApplication;
begin
  case imgType of
    imgPNG: xContentType := 'image/png';
    imgJPEG: xContentType := 'image/jpeg';
    imgGIF: xContentType := 'image/gif';
    imgBMP: xContentType := 'image/bmp';
  end;

  ASession := GGetWebApplicationThreadVar();
//  xCacheStream := TCacheStream.Create(ASession);
  xCacheStream := TCacheStream.Create(ASession, TCacheType.ctSession);
//  xCacheStream := TCacheStream.Create(ASession, TCacheType.ctApp);
  xCacheStream.ContentType := xContentType;
  Result := xCacheStream.Href;

  try
    AGraphic.SaveToStream(xCacheStream.Stream);
  finally
    xCacheStream.Free;
  end;
end;

class function TIWAppCache.StreamToCacheFile(AStream: TMemoryStream;
  const ImgType: TIWImageType): string;
var
  xCacheStream: TCacheStream;
  xContentType: string;
  ASession: TIWApplication;
begin
  case imgType of
    imgPNG: xContentType := 'image/png';
    imgJPEG: xContentType := 'image/jpeg';
    imgGIF: xContentType := 'image/gif';
    imgBMP: xContentType := 'image/bmp';
  end;

  ASession := GGetWebApplicationThreadVar();
  xCacheStream := TCacheStream.Create(ASession);
  xCacheStream.ContentType := xContentType;
  Result := xCacheStream.Href;

  try
    AStream.Position := 0;
    AStream.SaveToStream(xCacheStream.Stream);
  finally
    xCacheStream.Free;
  end;
end;

{$ENDIF}

{$IFNDEF TMSIW14}
class function TIWAppCache.GraphicToCacheFile(AGraphic: TGraphic;
  const ImgType: TIWImageType): string;
begin
  case ImgType of
    imgJPEG: Result := GetNewCacheFile('jpeg',true);
    imgGIF: Result := GetNewCacheFile('gif',true);
    imgBMP: Result := GetNewCacheFile('bmp',true)
  end;
  AGraphic.SaveToFile(Result);

  Result := GServerController.UserCacheURL + ExtractFilename(Result);
end;

class function TIWAppCache.StreamToCacheFile(AStream: TMemoryStream;
  const ImgType: TIWImageType): string;
begin
  case ImgType of
    imgJPEG: Result := GetNewCacheFile('jpeg',true);
    imgGIF: Result := GetNewCacheFile('gif',true);
    imgBMP: Result := GetNewCacheFile('bmp',true)
  end;

  AStream.SaveToFile(Result);
  Result := GServerController.UserCacheURL + ExtractFilename(Result);
end;

{$ENDIF}


initialization

{$IFDEF FREEWARE}
   {$IFDEF TMSIW51}
   GLicense.ThirdPartyHook('TMS IntraWeb Components evaluation',True);
   {$ELSE}
   {$IFNDEF DELPHI7_LVL}
   GLicense.ThirdPartyHook('TMS IntraWeb Components evaluation',True);
   {$ELSE}
   AddThirdPartyLogo('TMS IntraWeb Components evaluation',True);
   {$ENDIF}
   {$ENDIF}
{$ENDIF}

end.
