문제

Ho do I load a memo control from external file

example: \res\info.txt

thanks

도움이 되었습니까?

해결책

It looks like the folks at SMS have come up with a quick and dirty solution until they can add a LoadFromUrl method in th TStringList

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

Their solution works by adding LoadFromURL method to the TStringList class via a helper object. The code below is copied from the Smart Mobile Studio forum and adjusted to work with Smart Mobile Studio 1.1. You can use it unitil TStringList.LoadFromUrl appears in the RTL.

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;

Just add this code to some unit and then use this unit in your project.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top