ギコナビ
Revision | 19c15d5c303c8d40ea351d54f51d7b4c46b4e6ff (tree) |
---|---|
Time | 2007-05-09 06:27:45 |
Author | h677 <h677> |
Commiter | h677 |
レスポップアップのフォントの設定、ウィンドウサイズの計算(バグあり)、クリック時の動作設定
@@ -4840,7 +4840,7 @@ begin | ||
4840 | 4840 | if ThreadItem <> nil then begin |
4841 | 4841 | Num := StrToInt64(s); |
4842 | 4842 | FHint.PopupType := gptThread; |
4843 | - HTMLCreater.SetResPopupText(FResPopupBrowser, ThreadItem, Num, Num, False, False); | |
4843 | + HTMLCreater.SetResPopupText(FResPopupBrowser.CreateNewBrowser, ThreadItem, Num, Num, False, False); | |
4844 | 4844 | if FHint.ResCount <> 0 then |
4845 | 4845 | ShowTextPopup; |
4846 | 4846 | Result := False; |
@@ -1288,7 +1288,6 @@ begin | ||
1288 | 1288 | if ThreadItem <> nil then begin |
1289 | 1289 | ResLink.FBbs := ThreadItem.ParentBoard.BBSID; |
1290 | 1290 | ResLink.FKey := ChangeFileExt(ThreadItem.FileName, ''); |
1291 | - Html.Add('<DL>'); | |
1292 | 1291 | //if ThreadItem.IsBoardPlugInAvailable then begin |
1293 | 1292 | if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin |
1294 | 1293 | //===== vOCÉæé\¦ |
@@ -1315,8 +1314,9 @@ begin | ||
1315 | 1314 | end; |
1316 | 1315 | end; |
1317 | 1316 | end; |
1318 | - Html.Add('</DL>'); | |
1319 | - Hint.Write(Html.Text); | |
1317 | + if (Html.Count > 0) then begin | |
1318 | + Hint.Write('<DL>' + Html.Text + '</DL>'); | |
1319 | + end; | |
1320 | 1320 | end; |
1321 | 1321 | finally |
1322 | 1322 | Html.Free; |
@@ -2,7 +2,7 @@ unit ResPopupBrowser; | ||
2 | 2 | interface |
3 | 3 | uses |
4 | 4 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, |
5 | - ActiveX, OleCtrls, HintWindow, | |
5 | + ActiveX, OleCtrls, HintWindow, | |
6 | 6 | {$IF Defined(DELPRO) } |
7 | 7 | SHDocVw, |
8 | 8 | MSHTML |
@@ -18,6 +18,7 @@ type | ||
18 | 18 | FChild :TResPopupBrowser; |
19 | 19 | FTitle :String; |
20 | 20 | FPopupType: TGikoPopupType; |
21 | + function GetBodyStyle(): string; | |
21 | 22 | protected |
22 | 23 | procedure CreateParams(var Params: TCreateParams); override; |
23 | 24 | public |
@@ -43,6 +44,7 @@ begin | ||
43 | 44 | inherited Create(AOwner); |
44 | 45 | FChild := nil; |
45 | 46 | Visible := False; |
47 | + Title := ''; | |
46 | 48 | end; |
47 | 49 | |
48 | 50 | destructor TResPopupBrowser.Destroy; |
@@ -69,6 +71,7 @@ begin | ||
69 | 71 | FChild.NavigateBlank; |
70 | 72 | FChild.OnEnter := GikoForm.BrowserEnter; |
71 | 73 | FChild.OnStatusTextChange := GikoForm.BrowserStatusTextChange; |
74 | + FChild.OnNewWindow2 := GikoForm.BrowserNewWindow2; | |
72 | 75 | ShowWindow(FChild.Handle, SW_HIDE); |
73 | 76 | Result := FChild; |
74 | 77 | end; |
@@ -77,6 +80,7 @@ begin | ||
77 | 80 | Self.NavigateBlank; |
78 | 81 | Self.OnEnter := GikoForm.BrowserEnter; |
79 | 82 | Self.OnStatusTextChange := GikoForm.BrowserStatusTextChange; |
83 | + Self.OnNewWindow2 := GikoForm.BrowserNewWindow2; | |
80 | 84 | Result := Self; |
81 | 85 | end; |
82 | 86 |
@@ -96,30 +100,68 @@ var | ||
96 | 100 | doc: Variant; |
97 | 101 | ARect: TRect; |
98 | 102 | begin |
103 | + Self.Visible := True; | |
104 | + ShowWindow(Self.Handle, SW_SHOW); | |
99 | 105 | try |
100 | 106 | doc := Idispatch( olevariant(Self.ControlInterface).Document) as IHTMLDocument2; |
101 | 107 | doc.open; |
102 | 108 | doc.charset := 'Shift_JIS'; |
103 | - doc.Write('<html><body topmargin="2" leftmargin="2" style="border-width: 1px; border-style: solid;white-space: nowrap">' | |
104 | - + ADocument + '</body></html>'); | |
109 | + doc.Write('<html><head>'#13#10 + | |
110 | + '<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">'#13#10 + | |
111 | + Title + GetBodyStyle + '</head><body>' + | |
112 | + ADocument + '</body></html>'); | |
105 | 113 | doc.Close; |
106 | - Self.Visible := True; | |
107 | 114 | |
108 | - ARect := CalcRect(Screen.Width); | |
109 | - SetWindowPos(Self.Handle, HWND_TOPMOST, | |
115 | + while (Self.ReadyState <> READYSTATE_COMPLETE) and | |
116 | + (Self.ReadyState <> READYSTATE_INTERACTIVE) do begin | |
117 | + Sleep(1); | |
118 | + Forms.Application.ProcessMessages; | |
119 | + end; | |
120 | + | |
121 | + ARect := CalcRect(Screen.Width); | |
122 | + SetWindowPos(Self.Handle, HWND_TOPMOST, | |
110 | 123 | ARect.Left, ARect.Top, |
111 | 124 | (ARect.Right - ARect.Left) , |
112 | 125 | (ARect.Bottom - ARect.Top), |
113 | 126 | SWP_NOACTIVATE or SWP_HIDEWINDOW); |
114 | 127 | |
115 | - ShowWindow(Self.Handle, SW_SHOWNOACTIVATE); | |
128 | + ShowWindow(Self.Handle, SW_SHOWNOACTIVATE); | |
129 | + | |
116 | 130 | except |
117 | 131 | end; |
132 | + | |
118 | 133 | end; |
134 | + | |
135 | +function TResPopupBrowser.GetBodyStyle(): string; | |
136 | +begin | |
137 | + | |
138 | + Result := '<style type="text/css">' + | |
139 | + 'dl { margin :0px; padding :0px}'#13#10 + | |
140 | + 'body { ' + | |
141 | + 'border-width: 1px; border-style: solid;white-space: nowrap; ' + | |
142 | + 'margin: 2px 4px 0px 0px; padding: 0px 4px 0px 0px'; | |
143 | + | |
144 | + if Length( GikoSys.Setting.HintFontName ) > 0 then | |
145 | + Result := Result + 'font-family:"' + GikoSys.Setting.HintFontName + '";'; | |
146 | + if GikoSys.Setting.HintFontSize <> 0 then | |
147 | + Result := Result + 'font-size:' + IntToStr( GikoSys.Setting.HintFontSize ) + 'pt;'; | |
148 | + if GikoSys.Setting.HintFontColor <> -1 then | |
149 | + Result := Result + 'color:#' + IntToHex( GikoSys.Setting.HintFontColor, 6 ) + ';'; | |
150 | + if GikoSys.Setting.HintBackColor <> -1 then | |
151 | + Result := Result + 'background-color:#' + | |
152 | + IntToHex( | |
153 | + (GikoSys.Setting.HintBackColor shr 16) or | |
154 | + (GikoSys.Setting.HintBackColor and $ff00) or | |
155 | + ((GikoSys.Setting.HintBackColor and $ff) shl 16), 6 ) + ';'; | |
156 | + | |
157 | + Result := Result + '}</style>'; | |
158 | +end; | |
159 | + | |
119 | 160 | procedure TResPopupBrowser.Clear; |
120 | 161 | begin |
121 | 162 | ChildClear; |
122 | 163 | if (Self.Visible) then begin |
164 | + Self.Title := ''; | |
123 | 165 | Self.Visible := False; |
124 | 166 | ShowWindow(Self.Handle, SW_HIDE); |
125 | 167 | end; |
@@ -134,19 +176,24 @@ end; | ||
134 | 176 | function TResPopupBrowser.CalcRect(MaxWidth: Integer): TRect; |
135 | 177 | var |
136 | 178 | p: TPoint; |
179 | + doc: Variant; | |
180 | + ele: IHTMLElement2; | |
137 | 181 | begin |
138 | 182 | GetCursorpos(p); |
139 | - Result := Rect(0, 0, 500, 200); | |
183 | + ele := ((Self.Document as IHTMLDocument2).body as IHTMLElement2); | |
184 | + Result := Rect(0, 0, | |
185 | + ele.scrollWidth + 15, | |
186 | + ele.scrollHeight + 15); | |
140 | 187 | case GikoSys.Setting.PopupPosition of |
141 | - gppRightTop: OffsetRect(Result, p.x - (Result.Right - Result.Left) - 5, p.y - (Result.Bottom - Result.Top) - 5); | |
142 | - gppRight: OffsetRect(Result, p.x - (Result.Right - Result.Left) - 5, p.y - ((Result.Bottom - Result.Top) div 2)); | |
143 | - gppRightBottom: OffsetRect(Result, p.x - (Result.Right - Result.Left) - 5, p.y + 5); | |
144 | - gppTop: OffsetRect(Result, p.x - ((Result.Right - Result.Left) div 2), p.y - (Result.Bottom - Result.Top) - 5); | |
188 | + gppRightTop: OffsetRect(Result, p.x - (Result.Right - Result.Left), p.y - (Result.Bottom - Result.Top)); | |
189 | + gppRight: OffsetRect(Result, p.x - (Result.Right - Result.Left), p.y - ((Result.Bottom - Result.Top) div 2)); | |
190 | + gppRightBottom: OffsetRect(Result, p.x - (Result.Right - Result.Left), p.y); | |
191 | + gppTop: OffsetRect(Result, p.x - ((Result.Right - Result.Left) div 2), p.y - (Result.Bottom - Result.Top)); | |
145 | 192 | gppCenter: OffsetRect(Result, p.x - ((Result.Right - Result.Left) div 2), p.y - ((Result.Bottom - Result.Top) div 2)); |
146 | - gppBottom: OffsetRect(Result, p.x - ((Result.Right - Result.Left) div 2), p.y + 5); | |
147 | - gppLeftTop: OffsetRect(Result, p.x + 5, p.y - (Result.Bottom - Result.Top) - 5); | |
148 | - gppLeft: OffsetRect(Result, p.x + 5, p.y - ((Result.Bottom - Result.Top) div 2)); | |
149 | - gppLeftBottom: OffsetRect(Result, p.x + 5, p.y + 5); //MRirX p[gPÌ453É´Ó | |
193 | + gppBottom: OffsetRect(Result, p.x - ((Result.Right - Result.Left) div 2), p.y); | |
194 | + gppLeftTop: OffsetRect(Result, p.x, p.y - (Result.Bottom - Result.Top)); | |
195 | + gppLeft: OffsetRect(Result, p.x, p.y - ((Result.Bottom - Result.Top) div 2)); | |
196 | + gppLeftBottom: OffsetRect(Result, p.x, p.y); | |
150 | 197 | end; |
151 | 198 | if (Result.Left < 0) then begin |
152 | 199 | OffsetRect(Result, -Result.Left, 0); |
@@ -154,7 +201,6 @@ begin | ||
154 | 201 | if (Result.Top < 0) then begin |
155 | 202 | OffsetRect(Result, 0, -Result.Top); |
156 | 203 | end; |
157 | - | |
158 | 204 | end; |
159 | 205 | |
160 | 206 | end. |