whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

47 Visitors Online


 
...set the focus on a TWebbrowser?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (22):  
     


{
  Jeder der mal TWebBrowser.SetFocus ausprobiert hat,
  musste feststellen, dass der Fokus nicht auf das Webbrowser
  Dokument (eine Webseite) setzt, sondern auf das Webbrowser Control,
  was uns nicht gerade viel bringt.
  Hier werden zwei Möglichkeiten beschrieben, wie man den Fokus auf
  die "Webseite" (d.h Dokument des Webbrowser) setzen kann.
{

{
  Anyone that has worked with TWebBrowser knows that the
  TWebBrowser.SetFocus procedure doesn't set focus on the "web page",
  but rather on the control itself, which doesn't do us a whole lot of good.
  Here are two possibilities to set the focus on the "web page" (i.e., document):
}


{1}

uses
  
ActiveX;

begin
  
WebBrowser1.Navigate('irgendeinedatei.html');
  with WebBrowser1 do
  if 
Document <> nil then
    with 
Application as IOleobject do
      
DoVerb(OLEIVERB_UIACTIVATE, nil, WebBrowser1, 0, Handle,
        GetClientRect);
end;

{2}

uses
  
MSHTML;

begin
  
WebBrowser1.Navigate('irgendeinedatei.html');
  repeat
    
Application.ProcessMessages;
  until WebBrowser1.ReadyState >= READYSTATE_COMPLETE;
  if WebBrowser1.Document <> nil then
  
(Webbrowser1.Document as IHTMLDocument2).ParentWindow.Focus;
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners