5 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
14 TPreviewBrowser = class(TWebBrowser)
17 procedure CreateParams(var Params: TCreateParams); override;
19 constructor Create(AOwner: TComponent); override;
20 destructor Destroy; override;
21 procedure PreviewImage(URL : String);
22 function GetWindowRect(Point: TPoint) : TRect;
26 uses MojuUtils, GikoSystem, Setting;
29 //
\83v
\83\8c\83r
\83\85\81[
\83t
\83@
\83C
\83\8b\96¼
30 HTML_FILE_NAME = 'temp_preview.html';
31 //
\83}
\83E
\83X
\83J
\81[
\83\
\83\8b\82©
\82ç
\82Ì
\82¸
\82ç
\82µ
\88Ê
\92u
35 constructor TPreviewBrowser.Create(AOwner: TComponent);
37 inherited Create(AOwner);
40 destructor TPreviewBrowser.Destroy;
45 procedure TPreviewBrowser.CreateParams(var Params: TCreateParams);
50 \brief
\8ew
\92è
\82³
\82ê
\82½URL
\82Ì
\83v
\83\8c\83r
\83\85\81[
51 \param URL
\83v
\83\8c\83r
\83\85\81[
\82·
\82é
\83C
\83\81\81[
\83W
\82ÌURL
53 procedure TPreviewBrowser.PreviewImage(URL : String);
56 HtmlFileName : string;
58 Protocol, Host, Path, Document, Port, Bookmark : string;
61 TargetFrameName: OleVariant;
65 html := '<html><head>'#13#10
67 + 'function init() {'#13#10
68 + ' if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
70 + ' var dh, ih;'#13#10
71 + ' dh = document.body.clientWidth / document.body.clientHeight;'#13#10
72 + ' ih = Image1.width / Image1.height;'#13#10
73 + ' if (document.body.clientWidth < document.body.clientHeight) {'#13#10
74 + ' if (ih > dh)'#13#10
75 + ' Image1.width = document.body.clientWidth;'#13#10
77 + ' Image1.height = document.body.clientHeight;'#13#10
79 + ' if (ih < dh)'#13#10
80 + ' Image1.height = document.body.clientHeight;'#13#10
82 + ' Image1.width = document.body.clientWidth;'#13#10
85 + ' Message.style.display = "none";'#13#10
89 + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
90 + '<div align="center" id="Message">
\83v
\83\8c\83r
\83\85\81[
\8dì
\90¬
\92\86</div>'#13#10
91 + '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
94 HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
95 sl := TStringList.Create;
99 CustomStringReplace(html, '%ImageURL%', URL, False);
100 sl.SaveToFile(HtmlFileName);
107 GikoSys.ParseURI(URL, Protocol, Host, Path, Document, Port, Bookmark);
108 Referer := Protocol + '://' + Host;
110 Referer := Referer + ':' + Port;
111 Referer := Referer + Path;
112 Headers := 'Referer: ' + Referer;
114 TargetFrameName := '';
117 Navigate(HtmlFileName,Flags, TargetFrameName, PostData, Headers);
121 \breif
\95\
\8e¦
\82·
\82é
\83E
\83B
\83\93\83h
\83E
\83T
\83C
\83Y
\82ð
\8eæ
\93¾
\82·
\82é
122 \param Point
\83}
\83E
\83X
\83J
\81[
\83\
\83\8b\82Ì
\8dÀ
\95W
124 function TPreviewBrowser.GetWindowRect(Point: TPoint) : TRect;
126 WindowWidth, WindowHeight : Integer;
128 //
\90Ý
\92è
\82É
\82æ
\82é
\8fê
\8d\87\82í
\82¯
129 case GikoSys.Setting.PreviewSize of
146 else begin //gpsMedium
152 Result := Rect(0, 0, WindowWidth, WindowHeight);
153 // bata55
\88È
\91O
\82Í
\8d¶
\89E
\82ª
\8aÔ
\88á
\82Á
\82Ä
\82½
154 //
\8fo
\82µ
\88Ê
\92u
\82É
\82æ
\82é
\95â
\90³
155 case GikoSys.Setting.PopupPosition of
156 gppLeftTop: OffsetRect(Result,
157 Point.x - WindowWidth - DIV_X, Point.y - WindowHeight - DIV_Y);
158 gppLeft: OffsetRect(Result,
159 Point.x - WindowWidth - DIV_X, Point.y - (WindowHeight div 2));
160 gppLeftBottom: OffsetRect(Result,
161 Point.x - WindowWidth - DIV_X, Point.y + DIV_Y);
162 gppTop: OffsetRect(Result,
163 Point.x - (WindowWidth div 2), Point.y - WindowHeight - DIV_Y);
164 gppCenter: OffsetRect(Result,
165 Point.x - (WindowWidth div 2), Point.y - (WindowHeight div 2));
166 gppBottom: OffsetRect(Result,
167 Point.x - (WindowWidth div 2), Point.y + DIV_Y);
168 gppRightTop: OffsetRect(Result,
169 Point.x + DIV_X, Point.y - WindowHeight - DIV_Y);
170 gppRight: OffsetRect(Result,
171 Point.x + DIV_X, Point.y - (WindowHeight div 2));
172 gppRightBottom: OffsetRect(Result, Point.x + DIV_X, Point.y + DIV_Y); //
\83M
\83R
\83i
\83r
\83X
\83\8c \83p
\81[
\83g
\82P
\82Ì453
\8e\81\82É
\8a´
\8eÓ