5 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
14 TPreviewBrowser = class(TWebBrowser)
16 function makeHTML(const URL, Host, Document : String): String;
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';
32 //
\83}
\83E
\83X
\83J
\81[
\83\
\83\8b\82©
\82ç
\82Ì
\82¸
\82ç
\82µ
\88Ê
\92u
35 NICO = 'www.nicovideo.jp';
37 constructor TPreviewBrowser.Create(AOwner: TComponent);
39 inherited Create(AOwner);
42 destructor TPreviewBrowser.Destroy;
47 procedure TPreviewBrowser.CreateParams(var Params: TCreateParams);
52 \brief
\8ew
\92è
\82³
\82ê
\82½URL
\82Ì
\83v
\83\8c\83r
\83\85\81[
53 \param URL
\83v
\83\8c\83r
\83\85\81[
\82·
\82é
\83C
\83\81\81[
\83W
\82ÌURL
55 procedure TPreviewBrowser.PreviewImage(URL : String);
57 HtmlFileName : string;
59 Protocol, Host, Path, Document, Port, Bookmark : string;
62 TargetFrameName: OleVariant;
66 GikoSys.ParseURI(URL, Protocol, Host, Path, Document, Port, Bookmark);
67 Referer := Protocol + '://' + Host;
69 Referer := Referer + ':' + Port;
70 Referer := Referer + Path;
71 Headers := 'Referer: ' + Referer;
73 TargetFrameName := '';
76 HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
77 sl := TStringList.Create;
80 sl.Text := makeHTML(URL, Host, Document);
81 sl.SaveToFile(HtmlFileName);
89 Navigate(HtmlFileName,Flags, TargetFrameName, PostData, Headers);
93 \breif
\95\
\8e¦
\82·
\82é
\83E
\83B
\83\93\83h
\83E
\83T
\83C
\83Y
\82ð
\8eæ
\93¾
\82·
\82é
94 \param Point
\83}
\83E
\83X
\83J
\81[
\83\
\83\8b\82Ì
\8dÀ
\95W
96 function TPreviewBrowser.GetWindowRect(Point: TPoint) : TRect;
98 WindowWidth, WindowHeight : Integer;
100 //
\90Ý
\92è
\82É
\82æ
\82é
\8fê
\8d\87\82í
\82¯
101 case GikoSys.Setting.PreviewSize of
118 else begin //gpsMedium
124 Result := Rect(0, 0, WindowWidth, WindowHeight);
125 // bata55
\88È
\91O
\82Í
\8d¶
\89E
\82ª
\8aÔ
\88á
\82Á
\82Ä
\82½
126 //
\8fo
\82µ
\88Ê
\92u
\82É
\82æ
\82é
\95â
\90³
127 case GikoSys.Setting.PopupPosition of
128 gppLeftTop: OffsetRect(Result,
129 Point.x - WindowWidth - DIV_X, Point.y - WindowHeight - DIV_Y);
130 gppLeft: OffsetRect(Result,
131 Point.x - WindowWidth - DIV_X, Point.y - (WindowHeight div 2));
132 gppLeftBottom: OffsetRect(Result,
133 Point.x - WindowWidth - DIV_X, Point.y + DIV_Y);
134 gppTop: OffsetRect(Result,
135 Point.x - (WindowWidth div 2), Point.y - WindowHeight - DIV_Y);
136 gppCenter: OffsetRect(Result,
137 Point.x - (WindowWidth div 2), Point.y - (WindowHeight div 2));
138 gppBottom: OffsetRect(Result,
139 Point.x - (WindowWidth div 2), Point.y + DIV_Y);
140 gppRightTop: OffsetRect(Result,
141 Point.x + DIV_X, Point.y - WindowHeight - DIV_Y);
142 gppRight: OffsetRect(Result,
143 Point.x + DIV_X, Point.y - (WindowHeight div 2));
144 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Ó
150 \breif
\83v
\83\8c\83r
\83\85\81[
\97p
\82ÌHTML
\82ð
\8dì
\90¬
\82·
\82é
151 \param URL
\83v
\83\8c\83r
\83\85\81[
\82·
\82é
\83C
\83\81\81[
\83W
\83t
\83@
\83C
\83\8b
153 function TPreviewBrowser.makeHTML(const URL, Host, Document : String): String;
158 if (Pos('http://www.nicovideo.jp/watch/', URL) <> 1) then begin
159 Result := '<html><head>'#13#10
161 + 'function init() {'#13#10
162 + ' if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
164 + ' var dh, ih;'#13#10
165 + ' dh = document.body.clientWidth / document.body.clientHeight;'#13#10
166 + ' ih = Image1.width / Image1.height;'#13#10
167 + ' if (document.body.clientWidth < document.body.clientHeight) {'#13#10
168 + ' if (ih > dh)'#13#10
169 + ' Image1.width = document.body.clientWidth;'#13#10
171 + ' Image1.height = document.body.clientHeight;'#13#10
173 + ' if (ih < dh)'#13#10
174 + ' Image1.height = document.body.clientHeight;'#13#10
176 + ' Image1.width = document.body.clientWidth;'#13#10
179 + ' Message.style.display = "none";'#13#10
183 + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
184 + '<div align="center" id="Message">
\83v
\83\8c\83r
\83\85\81[
\8dì
\90¬
\92\86</div>'#13#10
185 + '<div align="center"><img name="Image1" border="0" src="' + URL + '"></div>'#13#10
188 // <div><iframe width="340" height="185" src="http://www.nicovideo.jp/thumb/sm2494604" scrolling="no" style="border:solid 1px #CCC;" frameborder="0"></iframe></div><div class=link_nicovideo_title><a href="" title="" target="_blank"></a></div>
189 rect := GetWindowRect(point);
191 Result := '<html><head>'#13#10
193 + 'function init() {'#13#10
194 + ' Message.style.display = "none";'#13#10
198 + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
199 + '<div align="center" id="Message">
\83v
\83\8c\83r
\83\85\81[
\8dì
\90¬
\92\86</div>'#13#10
200 + '<div><iframe width="' + IntToStr(rect.Right - rect.Left) +'" height="' + IntToStr(rect.Bottom - rect.Top) + '" src="http://' + Host + '/thumb/' + Document + '" scrolling="no" style="border:solid 1px #CCC;" frameborder="0"></iframe></div>'