ギコナビ
Revision | 32dd222766593778018385afa93d4abc10c28f16 (tree) |
---|---|
Time | 2007-05-11 00:29:42 |
Author | h677 <h677> |
Commiter | h677 |
背景色の設定、フォント設定、ウィンドウサイズ、ウィンドウ位置
の不具合の修正
@@ -19,6 +19,7 @@ type | ||
19 | 19 | FTitle :String; |
20 | 20 | FPopupType: TGikoPopupType; |
21 | 21 | function GetBodyStyle(): string; |
22 | + function GetWindowHeight : Integer; | |
22 | 23 | protected |
23 | 24 | procedure CreateParams(var Params: TCreateParams); override; |
24 | 25 | public |
@@ -31,7 +32,7 @@ type | ||
31 | 32 | procedure Clear; |
32 | 33 | procedure ChildClear; |
33 | 34 | procedure NavigateBlank; |
34 | - function CalcRect(MaxWidth: Integer): TRect; | |
35 | + function CalcRect(MaxHeight: Integer; MaxWidth: Integer): TRect; | |
35 | 36 | property PopupType: TGikoPopupType read FPopupType write FPopupType; |
36 | 37 | end; |
37 | 38 |
@@ -103,43 +104,43 @@ var | ||
103 | 104 | ARect: TRect; |
104 | 105 | begin |
105 | 106 | try |
107 | + // ¢Á½ñk¬ | |
108 | + SetWindowPos(Self.Handle, HWND_TOP, | |
109 | + 0, 0, 50 , 50, | |
110 | + SWP_NOMOVE or SWP_NOACTIVATE or SWP_HIDEWINDOW); | |
111 | + | |
106 | 112 | doc := Idispatch( olevariant(Self.ControlInterface).Document) as IHTMLDocument2; |
107 | 113 | doc.open; |
108 | 114 | doc.charset := 'Shift_JIS'; |
109 | 115 | doc.Write('<html><head>'#13#10 + |
110 | 116 | '<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">'#13#10 + |
111 | 117 | Title + GetBodyStyle + '</head><body>' + |
112 | - ADocument + '</body></html>'); | |
118 | + ADocument + '<a name="bottom"></a></body></html>'); | |
113 | 119 | doc.Close; |
114 | 120 | |
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); | |
121 | + ARect := CalcRect(Screen.Height, Screen.Width); | |
122 | 122 | SetWindowPos(Self.Handle, HWND_TOP, |
123 | 123 | ARect.Left, ARect.Top, |
124 | 124 | (ARect.Right - ARect.Left) , |
125 | 125 | (ARect.Bottom - ARect.Top), |
126 | 126 | SWP_NOACTIVATE or SWP_HIDEWINDOW); |
127 | - Self.Visible := True; | |
128 | 127 | ShowWindow(Self.Handle, SW_SHOWNOACTIVATE); |
129 | - | |
128 | + Self.Visible := True; | |
130 | 129 | except |
131 | 130 | end; |
132 | 131 | |
133 | 132 | end; |
134 | 133 | |
135 | 134 | function TResPopupBrowser.GetBodyStyle(): string; |
135 | +var | |
136 | + i : Integer; | |
136 | 137 | begin |
137 | 138 | |
138 | 139 | Result := '<style type="text/css">' + |
139 | 140 | 'dl { margin :0px; padding :0px}'#13#10 + |
140 | 141 | 'body { ' + |
141 | 142 | 'border-width: 1px; border-style: solid;white-space: nowrap; ' + |
142 | - 'margin: 2px 4px 0px 0px; padding: 0px 4px 0px 0px'; | |
143 | + 'margin: 2px 4px 0px 0px; padding: 0px 4px 0px 0px; '; | |
143 | 144 | |
144 | 145 | if Length( GikoSys.Setting.HintFontName ) > 0 then |
145 | 146 | Result := Result + 'font-family:"' + GikoSys.Setting.HintFontName + '";'; |
@@ -147,12 +148,11 @@ begin | ||
147 | 148 | Result := Result + 'font-size:' + IntToStr( GikoSys.Setting.HintFontSize ) + 'pt;'; |
148 | 149 | if GikoSys.Setting.HintFontColor <> -1 then |
149 | 150 | Result := Result + 'color:#' + IntToHex( GikoSys.Setting.HintFontColor, 6 ) + ';'; |
150 | - if GikoSys.Setting.HintBackColor <> -1 then | |
151 | + if GikoSys.Setting.HintBackColor <> -1 then begin | |
152 | + i := ColorToRGB( GikoSys.Setting.HintBackColor ); | |
151 | 153 | 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 ) + ';'; | |
154 | + IntToHex( (i shr 16) or (i and $ff00) or ((i and $ff) shl 16), 6 ) + ';'; | |
155 | + end; | |
156 | 156 | |
157 | 157 | Result := Result + '}</style>'; |
158 | 158 | end; |
@@ -173,25 +173,26 @@ begin | ||
173 | 173 | end; |
174 | 174 | end; |
175 | 175 | |
176 | -function TResPopupBrowser.CalcRect(MaxWidth: Integer): TRect; | |
176 | +function TResPopupBrowser.CalcRect(MaxHeight: Integer; MaxWidth: Integer): TRect; | |
177 | 177 | var |
178 | 178 | p: TPoint; |
179 | 179 | ele: IHTMLElement2; |
180 | + h, w: Integer; | |
180 | 181 | begin |
181 | 182 | GetCursorpos(p); |
182 | 183 | ele := ((Self.Document as IHTMLDocument2).body as IHTMLElement2); |
183 | - Result := Rect(0, 0, | |
184 | - ele.scrollWidth + 15, | |
185 | - ele.scrollHeight + 15); | |
184 | + h := GetWindowHeight + 25; | |
185 | + w := ele.scrollWidth + 25; | |
186 | + Result := Rect(0, 0, w, h); | |
186 | 187 | case GikoSys.Setting.PopupPosition of |
187 | - gppRightTop: OffsetRect(Result, p.x - (Result.Right - Result.Left) - 2, p.y - (Result.Bottom - Result.Top) - 2); | |
188 | - gppRight: OffsetRect(Result, p.x - (Result.Right - Result.Left) - 2, p.y - ((Result.Bottom - Result.Top) div 2)); | |
189 | - gppRightBottom: OffsetRect(Result, p.x - (Result.Right - Result.Left) -2, p.y + 2); | |
190 | - gppTop: OffsetRect(Result, p.x - ((Result.Right - Result.Left) div 2), p.y - (Result.Bottom - Result.Top) - 2); | |
191 | - gppCenter: OffsetRect(Result, p.x - ((Result.Right - Result.Left) div 2), p.y - ((Result.Bottom - Result.Top) div 2)); | |
192 | - gppBottom: OffsetRect(Result, p.x - ((Result.Right - Result.Left) div 2), p.y + 2); | |
193 | - gppLeftTop: OffsetRect(Result, p.x + 2, p.y - (Result.Bottom - Result.Top) - 2); | |
194 | - gppLeft: OffsetRect(Result, p.x + 2, p.y - ((Result.Bottom - Result.Top) div 2)); | |
188 | + gppRightTop: OffsetRect(Result, p.x - w - 2, p.y - h - 2); | |
189 | + gppRight: OffsetRect(Result, p.x - w - 2, p.y - (h div 2)); | |
190 | + gppRightBottom: OffsetRect(Result, p.x - w -2, p.y + 2); | |
191 | + gppTop: OffsetRect(Result, p.x - (w div 2), p.y - h - 2); | |
192 | + gppCenter: OffsetRect(Result, p.x - (w div 2), p.y - (h div 2)); | |
193 | + gppBottom: OffsetRect(Result, p.x - (w div 2), p.y + 2); | |
194 | + gppLeftTop: OffsetRect(Result, p.x + 2, p.y - h - 2); | |
195 | + gppLeft: OffsetRect(Result, p.x + 2, p.y - (h div 2)); | |
195 | 196 | gppLeftBottom: OffsetRect(Result, p.x + 2, p.y + 2); |
196 | 197 | end; |
197 | 198 | if (Result.Left < 0) then begin |
@@ -200,6 +201,45 @@ begin | ||
200 | 201 | if (Result.Top < 0) then begin |
201 | 202 | OffsetRect(Result, 0, -Result.Top); |
202 | 203 | end; |
204 | + if (Result.Right > MaxWidth) then begin | |
205 | + OffsetRect(Result, - (Result.Right - MaxWidth), 0); | |
206 | + end; | |
207 | + if (Result.Bottom > MaxHeight) then begin | |
208 | + OffsetRect(Result, 0, - (Result.Bottom - MaxHeight)); | |
209 | + end; | |
210 | + // ±±ÅÄx¶ÆãðmFµÄòÑoµÄ½çAæÊTCY𬳷é | |
211 | + if (Result.Left < 0) then begin | |
212 | + Result := Rect(0, Result.Top, | |
213 | + Result.Right, Result.Bottom); | |
214 | + end; | |
215 | + if (Result.Top < 0) then begin | |
216 | + Result := Rect(Result.Left, 0, | |
217 | + Result.Right, Result.Bottom); | |
218 | + end; | |
203 | 219 | end; |
220 | +function TResPopupBrowser.GetWindowHeight : Integer; | |
221 | +var | |
222 | + top: Integer; | |
223 | + item: OleVariant; | |
224 | +begin | |
225 | + //uEUªf[^ÌÇÝÝÌÍÇÝÝðÒÂ | |
226 | + while (Self.ReadyState <> READYSTATE_COMPLETE) and | |
227 | + (Self.ReadyState <> READYSTATE_INTERACTIVE) do begin | |
228 | + Sleep(1); | |
229 | + Forms.Application.ProcessMessages; | |
230 | + end; | |
204 | 231 | |
232 | + try | |
233 | + top := 0; | |
234 | + item := OleVariant( Self.Document as IHTMLDocument2) | |
235 | + .anchors.item(OleVariant('bottom')); | |
236 | + item.focus(); | |
237 | + repeat | |
238 | + top := top + item.offsetTop; | |
239 | + item := item.offsetParent; | |
240 | + until AnsiCompareText(item.tagName, 'body' ) = 0; | |
241 | + Result := top; | |
242 | + except | |
243 | + end; | |
244 | +end; | |
205 | 245 | end. |