Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/BrowserRecord.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.8 by h677, Sat Mar 1 15:34:33 2008 UTC revision 1.9 by eggcake, Sun Apr 13 04:20:24 2008 UTC
# Line 62  end; Line 62  end;
62  // *************************************************************************  // *************************************************************************
63  destructor      TBrowserRecord.Destroy;  destructor      TBrowserRecord.Destroy;
64  var  var
65          doc :OleVariant;          doc :IHTMLDocument2;
66  begin  begin
67          if Self.FEvent <> nil then          if Self.FEvent <> nil then
68                  Self.FEvent.Free;                  Self.FEvent.Free;
69    
70          if Self.FBrowser <> nil then begin          if Self.FBrowser <> nil then begin
71                  if Self.Thread <> nil then begin                  if Self.Thread <> nil then begin
72                          //タブの復元で復元されたスレは、描画されていないときがあるので                          //タブの復元で復元されたスレは、描画されていないときがあるので
73                          //そのときのスクロール量を保存してしまうとトップに戻ってしまう。                          //そのときのスクロール量を保存してしまうとトップに戻ってしまう。
74                          if Self.FBrowser.OleObject.Document.documentElement.innerText <> '' then begin  
75                                  doc := Idispatch( olevariant(Self.FBrowser.ControlInterface).Document) as IHTMLDocument2;              try
76                                  Self.Thread.ScrollTop := doc.Body.ScrollTop;                  doc := Self.FBrowser.ControlInterface.Document as IHTMLDocument2;
77                          end;                  if Assigned(doc) then begin
78                        if (doc as IHTMLDocument3).documentElement.innerText <> '' then begin
79                            Self.Thread.ScrollTop := (doc.body as IHTMLElement2).scrollTop;
80                                end;
81                    end;
82                except
83                end;
84                  end;                  end;
85                  ShowWindow(Self.FBrowser.Handle, SW_HIDE);                  ShowWindow(Self.FBrowser.Handle, SW_HIDE);
86          end;          end;
# Line 86  procedure TBrowserRecord.Move(const ANam Line 93  procedure TBrowserRecord.Move(const ANam
93  var  var
94          top: Integer;          top: Integer;
95          item: OleVariant;          item: OleVariant;
96        doc : OleVariant;
97  begin  begin
98          //ブラウザが付いてるときだけ処理する          //ブラウザが付いてるときだけ処理する
99          if (Self.Browser <> nil) then begin      if not Assigned(Self.Browser) then
100                  //ブラウザがデータの読み込み中の時は読み込みを待つ          Exit;
                 while (Self.Browser.ReadyState <> READYSTATE_COMPLETE) and  
                                         (Self.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin  
                         Sleep(1);  
                         Application.ProcessMessages;  
                 end;  
101    
102                  try          //ブラウザがデータの読み込み中の時は読み込みを待つ
103                          top := 0;          while (Self.Browser.ReadyState <> READYSTATE_COMPLETE) and
104                          item := OleVariant( Self.Browser.Document as IHTMLDocument2)                          (Self.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
105                                          .anchors.item(OleVariant(AName));                  Sleep(1);
106                          item.focus();                  Application.ProcessMessages;
107                          repeat          end;
108                                  top := top + item.offsetTop;  
109                                  item := item.offsetParent;          try
110                          until AnsiCompareText(item.tagName, 'body' ) = 0;          doc := Self.Browser.OleObject.Document;
111                          OleVariant(Self.Browser.Document as IHTMLDocument2).body.scrollTop := top;                  top := 0;
112                  except                  item := doc.anchors.item(OleVariant(AName));
113                  end;                  item.focus();
114                    repeat
115                            top := top + item.offsetTop;
116                    item := item.offsetParent;
117                    until AnsiCompareText(item.tagName, 'body' ) = 0;
118                    doc.body.scrollTop := top;
119            except
120          end;          end;
121  end;  end;
122  // *************************************************************************  // *************************************************************************
123  //! ブラウザをスクロールさせる  //! ブラウザをスクロールさせる
124  // *************************************************************************  // *************************************************************************
125  procedure TBrowserRecord.Move(scroll: Integer);  procedure TBrowserRecord.Move(scroll: Integer);
126    var
127        doc: IHTMLDocument2;
128  begin  begin
129          //ブラウザが付いてるときだけ処理する          //ブラウザが付いてるときだけ処理する
130          if (Self.Browser <> nil) then begin      if not Assigned(Self.Browser) then
131                  //ブラウザがデータの読み込み中の時は読み込みを待つ          Exit;
                 while (Self.Browser.ReadyState <> READYSTATE_COMPLETE) and  
                                         (Self.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin  
                         Sleep(1);  
                         Application.ProcessMessages;  
                 end;  
132    
133                  try          //ブラウザがデータの読み込み中の時は読み込みを待つ
134                          OleVariant(Self.Browser.Document as IHTMLDocument2).body.scrollTop          while (Self.Browser.ReadyState <> READYSTATE_COMPLETE) and
135                  := OleVariant(Self.Browser.Document as IHTMLDocument2).body.scrollTop                                  (Self.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
136                      + scroll;                  Sleep(1);
137                  except                  Application.ProcessMessages;
138                  end;          end;
139    
140            try
141            doc := Self.Browser.ControlInterface.Document as IHTMLDocument2;
142                    (doc.body as IHTMLElement2).scrollTop := (doc.body as IHTMLElement2).scrollTop + scroll;
143            except
144          end;          end;
145  end;  end;
146    
# Line 140  const Line 151  const
151          HIDDEN = 'hidden';          HIDDEN = 'hidden';
152  var  var
153          firstElement: IHTMLElement;          firstElement: IHTMLElement;
154          document: IHTMLDocument2;          doc : IHTMLDocument2;
         docAll: IHTMLElementCollection;  
         doc : Variant;  
155          nCSS : string;          nCSS : string;
156  begin  begin
157          if Self.Browser <> nil then begin      if not Assigned(Self.Browser) then
158                  try          Exit;
                         document := Self.Browser.Document as IHTMLDocument2;  
159    
160                          if Assigned(document) then begin          try
161                                  docAll := document.all;                  doc := Self.Browser.ControlInterface.Document as IHTMLDocument2;
162                                  firstElement := docAll.item('idSearch', 0) as IHTMLElement;                  if not Assigned(doc) then
163                                  if (Assigned(firstElement)) then begin              Exit;
164                                          if Length(Abody) > 0 then begin  
165                                                  doc := Idispatch( olevariant(Self.Browser.ControlInterface).Document) as IHTMLDocument2;                  firstElement := doc.all.item('idSearch', 0) as IHTMLElement;
166                                                  nCSS := '<p id="idSearch" style="position:absolute;top:' + IntToStr(doc.Body.ScrollTop + 10) + 'px;right:5px;' //                  if not Assigned(firstElement) then
167                                                          + 'background-color:window; border:outset 1px infobackground; z-index:10; overflow-y:auto; border-top:none">'              Exit;
168                                                          + Abody + '</p>';  
169                                                  firstElement.outerHTML := nCSS;          try
170                                                  firstElement.style.visibility := 'visible';                  if Length(Abody) > 0 then begin
171                                          end else begin                          nCSS := '<p id="idSearch" style="position:absolute;top:' + IntToStr((doc.body as IHTMLElement2).ScrollTop + 10) + 'px;right:5px;' //
172                                                  firstElement.outerHTML := OUTER_HTML;                                  + 'background-color:window; border:outset 1px infobackground; z-index:10; overflow-y:auto; border-top:none">'
173                                                  firstElement.style.visibility := HIDDEN;                                      + Abody + '</p>';
174                                          end;                          firstElement.outerHTML := nCSS;
175                                  end else if (Assigned(firstElement)) then begin                          firstElement.style.visibility := 'visible';
176                                          firstElement.outerHTML := OUTER_HTML;                      end else begin
177                                          firstElement.style.visibility := HIDDEN;                              firstElement.outerHTML := OUTER_HTML;
178                                  end;                          firstElement.style.visibility := HIDDEN;
179                          end;                  end;
180                  except              except
181                  end;                      firstElement.outerHTML := OUTER_HTML;
182                            firstElement.style.visibility := HIDDEN;
183            end;
184    
185            except
186          end;          end;
187  end;  end;
188  {  {
# Line 185  var Line 197  var
197          vaIn, vaOut: OleVariant;          vaIn, vaOut: OleVariant;
198  begin  begin
199          if Assigned(Self.Browser) then begin          if Assigned(Self.Browser) then begin
                 vaIn  := 0;  
                 vaOut := 0;  
200                  try                  try
201                          CmdTarget := Self.Browser.ControlInterface.Document as IOleCommandTarget;                          CmdTarget := Self.Browser.ControlInterface.Document as IOleCommandTarget;
202                          if Assigned(CmdTarget) then begin                          if Assigned(CmdTarget) then begin

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26