5 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
15 TPreviewBrowser = class(TWebBrowser)
18 procedure CreateParams(var Params: TCreateParams); override;
20 constructor Create(AOwner: TComponent); override;
21 destructor Destroy; override;
22 procedure PreviewImage(URL : String);
23 function GetWindowRect(Point: TPoint) : TRect;
27 uses MojuUtils, GikoSystem, Setting;
30 //
\83v
\83\8c\83r
\83\85\81[
\83t
\83@
\83C
\83\8b\96¼
31 HTML_FILE_NAME = 'temp_preview.html';
33 constructor TPreviewBrowser.Create(AOwner: TComponent);
35 inherited Create(AOwner);
38 destructor TPreviewBrowser.Destroy;
43 procedure TPreviewBrowser.CreateParams(var Params: TCreateParams);
48 \brief
\8ew
\92è
\82³
\82ê
\82½URL
\82Ì
\83v
\83\8c\83r
\83\85\81[
49 \param URL
\83v
\83\8c\83r
\83\85\81[
\82·
\82é
\83C
\83\81\81[
\83W
\82ÌURL
51 procedure TPreviewBrowser.PreviewImage(URL : String);
54 HtmlFileName : string;
56 Protocol, Host, Path, Document, Port, Bookmark : string;
59 TargetFrameName: OleVariant;
63 html := '<html><head>'#13#10
65 + 'function init() {'#13#10
66 + ' if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
68 + ' var dh, ih;'#13#10
69 + ' dh = document.body.clientWidth / document.body.clientHeight;'#13#10
70 + ' ih = Image1.width / Image1.height;'#13#10
71 + ' if (document.body.clientWidth < document.body.clientHeight) {'#13#10
72 + ' if (ih > dh)'#13#10
73 + ' Image1.width = document.body.clientWidth;'#13#10
75 + ' Image1.height = document.body.clientHeight;'#13#10
77 + ' if (ih < dh)'#13#10
78 + ' Image1.height = document.body.clientHeight;'#13#10
80 + ' Image1.width = document.body.clientWidth;'#13#10
83 + ' Message.style.display = "none";'#13#10
87 + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
88 + '<div align="center" id="Message">
\83v
\83\8c\83r
\83\85\81[
\8dì
\90¬
\92\86</div>'#13#10
89 + '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
92 HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
93 sl := TStringList.Create;
97 CustomStringReplace(html, '%ImageURL%', URL, False);
98 sl.SaveToFile(HtmlFileName);
105 GikoSys.ParseURI(URL, Protocol, Host, Path, Document, Port, Bookmark);
106 Referer := Protocol + '://' + Host;
108 Referer := Referer + ':' + Port;
109 Referer := Referer + Path;
110 Headers := 'Referer: ' + Referer;
112 TargetFrameName := '';
115 Navigate(HtmlFileName,Flags, TargetFrameName, PostData, Headers);
119 \breif
\95\
\8e¦
\82·
\82é
\83E
\83B
\83\93\83h
\83E
\83T
\83C
\83Y
\82ð
\8eæ
\93¾
\82·
\82é
120 \param Point
\83}
\83E
\83X
\83J
\81[
\83\
\83\8b\82Ì
\8dÀ
\95W
122 function TPreviewBrowser.GetWindowRect(Point: TPoint) : TRect;
124 WindowWidth, WindowHeight : Integer;
126 //
\90Ý
\92è
\82É
\82æ
\82é
\8fê
\8d\87\82í
\82¯
127 case GikoSys.Setting.PreviewSize of
144 else begin //gpsMedium
150 Result := Rect(0, 0, WindowWidth, WindowHeight);
152 //
\8fo
\82µ
\88Ê
\92u
\82É
\82æ
\82é
\95â
\90³
153 case GikoSys.Setting.PopupPosition of
154 gppRightTop: OffsetRect(Result,
155 Point.x - WindowWidth - 15, Point.y - WindowHeight - 15);
156 gppRight: OffsetRect(Result,
157 Point.x - WindowWidth - 15, Point.y - (WindowHeight div 2));
158 gppRightBottom: OffsetRect(Result,
159 Point.x - WindowWidth - 15, Point.y + 15);
160 gppTop: OffsetRect(Result,
161 Point.x - (WindowWidth div 2), Point.y - WindowHeight - 15);
162 gppCenter: OffsetRect(Result,
163 Point.x - (WindowWidth div 2), Point.y - (WindowHeight div 2));
164 gppBottom: OffsetRect(Result,
165 Point.x - (WindowWidth div 2), Point.y + 15);
166 gppLeftTop: OffsetRect(Result,
167 Point.x + 15, Point.y - WindowHeight - 15);
168 gppLeft: OffsetRect(Result,
169 Point.x + 15, Point.y - (WindowHeight div 2));
170 gppLeftBottom: OffsetRect(Result, Point.x + 15, Point.y + 15); //
\83M
\83R
\83i
\83r
\83X
\83\8c \83p
\81[
\83g
\82P
\82Ì453
\8e\81\82É
\8a´
\8eÓ