AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Gecko Interface nutzen...

Ein Thema von Z4ppy · begonnen am 7. Jun 2010 · letzter Beitrag vom 2. Okt 2010
 
Z4ppy

Registriert seit: 25. Apr 2008
269 Beiträge
 
Delphi 7 Enterprise
 
#1

Gecko Interface nutzen...

  Alt 7. Jun 2010, 22:16
Ich hab absolut keine Ahnung, wie ich mit interfaces arbeiten muss ^^

Also: ich habe mir das Delphi Gecko SDK heruntergeladen, weil es damit einige Probleme bezüglich CSS2 und anderem gab, habe ich dann die neuste Version des originalen Gecko SDK integriert. Das funktioniert soweit auch (inklusive JS, Flash usw.).

Nun zu meinem Problem: Ich möchte gerne Klicks auf Links abfangen. Die TGeckoBrowser Komponente bietet zwar "OnLocationChange", das wird aber erst nach dem Laden ausgelöst. Ich möchte den Klick schon vorher abfangen und dann selber behandeln.

Nach viel Gesuche bin ich auf das Interface nsIContentPolicy gestossen mit der Methode shouldLoad(), was genau dem Punkt entspricht, an dem ich ansetzen muss, um mein Ziel zu erreichen. Meine Versuche, das zu implementieren sind allerdings nicht erfolgreich gewesen.
Ich möchte noch dazu sagen, dass ich bisher noch nie selbst Interfaces implementieren musste, ich hatte immer fertige Vorlagen

Mein Codeversuch:
Delphi-Quellcode:
type
  nsIContentPolicy = interface(nsISupports)
  ['{58cf9dca-40b3-6211-a508-7351f437a53e}']
    function shouldLoad(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeTypeGuess: nsISupports; aExtra: nsISupports): Cardinal; stdcall;
    function shouldProcess(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeType: nsISupports; aExtra: nsISupports): Cardinal; stdcall;
  end;

  TGeckoBrowserEx = class(TGeckoBrowser,nsIContentPolicy)
  private
    function shouldLoad(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeTypeGuess: nsISupports; aExtra: nsISupports): Cardinal; stdcall;
    function shouldProcess(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeType: nsISupports; aExtra: nsISupports): Cardinal; stdcall;
  end;

const
  REJECT_REQUEST = -1;
  REJECT_TYPE = -2;
  REJECT_SERVER = -3;
  REJECT_OTHER = -4;
  ACCEPT = 1;

var
  Form1: TForm1;
  GeckoBrowser1: TGeckoBrowserEx;

implementation

function TGeckoBrowserEx.shouldLoad(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeTypeGuess: nsISupports; aExtra: nsISupports): Cardinal;
begin
  Form1.Memo1.Lines.Add('asdf'); // zum Überprüfen, dass die Methode auch ausgeführt wurde :P In diesem Fall würde jetzt das Laden erlaubt...
  Result:=ACCEPT;
end;

function TGeckoBrowserEx.shouldProcess(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeType: nsISupports; aExtra: nsISupports): Cardinal;
begin
  Result:=ACCEPT;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  GeckoBrowser1:=TGeckoBrowserEx.Create(self);
  GeckoBrowser1.Parent:=Form1;
  GeckoBrowser1.Show;
  GeckoBrowser1.Top:=8;
  GeckoBrowser1.Left:=8;
  GeckoBrowser1.Width:=1200;
  GeckoBrowser1.Height:=472;
  GeckoBrowser1.LoadURI('http://www.google.com/'); // oder was auch immer, wo halt Links sind, die ich abfangen kann ^^
end;
Nunja, funktioniert genau gar nicht

Wie muss ich das machen?

MfG Z4ppy
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:41 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz