使用Smart Mobile Studio 1.1从外部文件加载备忘录控件

时间:2013-03-21 20:36:21

标签: smart-mobile-studio

我可以从外部文件加载备忘录控件

示例:\ res \ info.txt

感谢

1 个答案:

答案 0 :(得分:2)

看起来SMS的人们提出了一个快速而肮脏的解决方案,直到他们可以在TStringList中添加LoadFromUrl方法

http://smartmobilestudio.com/forums/topic/loading-memo-from-file-resinfo-txt/

他们的解决方案是通过辅助对象将LoadFromURL方法添加到TStringList类。以下代码是从Smart Mobile Studio论坛复制的,并经过调整后可与Smart Mobile Studio 1.1配合使用。您可以使用它在RTL中显示的单位TStringList.LoadFromUrl

type
  TStringlistHelper = class helper for TStringList
    procedure LoadFromUrl(aUrl:String;Callback: TProcedureRef = nil);
  end;

procedure TStringlistHelper.LoadFromUrl(aUrl:String;
            Callback:TProcedureRef);
var
  mRequest: TW3HttpRequest;
begin
  mRequest:=TW3HttpRequest.Create;
  mRequest.OnDataReady:=procedure (Sender:TW3HttpRequest)
  begin
    self.text:=Sender.ResponseText;
    if assigned(Callback) then Callback;
    w3_callback(sender.free,100);
  end;
  mRequest.Get(aUrl);
end;

只需将此代码添加到某个单元,然后在您的项目中使用此单元。