Web Application Opener - WebSnap!
Chapter, LocateFileService component
LocateFileService is a simple man, when Page Module wants to get the template, she will take the LocateFileService's interfacia to send the archive to give her, this file is required to have two kinds, one is you used in HTML Template to use the following order code:
The other is that when Page Module wants to get HTML Template, there are many purposes, and we want to hide HTML Template, such as hidden in other directories, and visitors cannot get our template file directly, or It is directly to put the template file in the program of the program. Dynamically removed, there is such an example in Demo / WebSnap, and sometimes we want to write Template in the program. At this time we can use LocateFileService. Event to process:
8-1 LocateFileService event
OnfindTemplatefile
In the example, there is a demolocateservice pagemodule, her HTML Template file is udemolocateservice.html, I hope to put her in a directory that is not read by the user:
procedure THome.LocateFileService1FindTemplateFile (ASender: TObject; AComponent: TComponent; const AFileName: String; var AFoundFile: String; var AHandled: Boolean); var I: Integer; fs: TFileStream; FN: array [0..255] of char; AppPath: string; begin GetModuleFileName (hInstance, FN, SizeOf (FN)); AppPath: = ExtractFileDir (FN); if aFileName = 'uDemoLocateService.html' then AFoundFile: = AppPath '/ Template / uDemoLocateService.html'; end;
The upper surface code promotes this file with /template/udemolocateService.html instead of the original udemolocateservice.html.
OnfindInCludefile
This event will be triggered when you have an incrude file command in your HTML Template.
ONFINDSTREAM
With the ONFindTemplateFile Touch, you can't use Stream to replace the actual file, which writes HTML Template in the process, or is used by HTML Template from resource. This chapter
LocateFileService is very simple, but it is useful, we can use her to write some need to dynamically change the network page, or you need to hide HTML Template, you will lose her, you have written a lot less.