Autor Beitrag
Delphi2009lover
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Fr 30.10.09 23:17 
Hi^^,

1. WIe kannan testen, ob man bei TWebbrowser überhaupt GoBack bzw GoForward derzeit geht. Also sowas wie

If Browser.CanGoForward Then Browser.GoBack^^

leider geht das ja nicht, gibts da sowas ähnliches?^^


2. Wie kann man den URL der gerade im TWebbrowser gezeigten seite ermitteln? Also sowas wie Browser.URL (geht ja ned)


währe cool wenn ihr eine Antwort habt!!! Thx schon mal im Vorraus
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 31.10.09 00:17 
Hallo,


1. Ereignis: WebBrowser.OnCommandStateChange
2. OleObject: WebBrowser.OleObject.Document.URL

3. Nur eine Frage pro Thema ...

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Sa 31.10.09 11:23 
Vielen Danke erstmal, aber ich glaub ich bin bei beiden zu dumm^^ könnt ihr mir nur bei zwei Sachen helfen?

Also zu 1 Der Code funktioniert klasse, aber ich will jetzt nicht, dass die Buttons Enabled = False sind, sondern einfach nicht das Kommando (GoBack / GoForward) ausführen. Ich habe es schon versucht bin nur kläglich gescheitert. Ich habe WordBool jetzt wie Boolean behandelt...

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
var
  YoubrowserForm: TYoubrowserForm;
  GoBackV : WordBool;
  GoForwardV : WordBool;
implementation

uses Main;

{$R *.dfm}

procedure TYoubrowserForm.BrowserOnCommandChange(ASender: TObject; Command: Integer;
  Enable: WordBool);
begin

case Command of
  CSC_NAVIGATEBACK: GoBackV := Enable;
  CSC_NAVIGATEFORWARD: GoBackV := Enable;
  end;


end;

procedure TYoubrowserForm.GoBackClick(Sender: TObject);
begin

If GoBackV Then Browser.GoBack;

end;

procedure TYoubrowserForm.GoForwardClick(Sender: TObject);
begin

If GoForwardV = False Then Browser.GoForward;

end;
(Browser : TWebborwser^^)

Währe nett wenn ihr sagen könntet was ich falsch verstanden hab...


zu 2

Sry hier steig ich garnicht durch (hab wohl die Variablennamen nicht richtig gelernt ;-) ) Ich bin hin und hab geschrieben:

ausblenden Delphi-Quelltext
1:
Label1.Caption := Browser.OleObject.Document.URL;					


Jah Fehler^^ ich bekomm leider jetzt nur noch den Fehler : "Zugriffsverletzung bei Adresse 0045C8AB in Modul 'Youtube_Downloader.exe'. Lesen von Adresse 00000000."

Währ nett wenn ihr nochmal helfen könntet^^
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 31.10.09 20:13 
Hallo,

warum prüfst Du in GoForwardClick auf False?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TYoubrowserForm.GoForwardClick(Sender: TObject);
begin
 //falsch: If GoForwardV = False Then Browser.GoForward;
 If GoForwardV Then Browser.GoForward;
end;


user profile iconDelphi2009lover hat folgendes geschrieben Zum zitierten Posting springen:
... Ich bin hin und hab geschrieben:
ausblenden Delphi-Quelltext
1:
Label1.Caption := Browser.OleObject.Document.URL;					
wo hast Du es hin geschrieben? Direkt nach webBrowser.Navigate? dann vermute ich das der Webbrowser noch nicht fertiggeladen hat.

Probier doch mal das:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
Browser.Navigate(...);
while Browser.ReadyState <> READYSTATE_COMPLETE do
  Application.ProcessMessages;
Label1.Caption := Browser.OleObject.Document.URL;

Kannst dir auch mal das Ereignis WebBrowser.OnDocumentComplete anschauen, das liefert Dir auch die URL.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Sa 31.10.09 21:28 
Okay gut, das mit dem URL habe ich verstanden^^ danke!! aber das mit dem Forward und Backward leider nicht... könnt ihr vllt einfach meinen Code verbessern?
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 31.10.09 23:28 
Hallo,

ich habe den Code doch schon verbessert :gruebel:
user profile iconLannes hat folgendes geschrieben Zum zitierten Posting springen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TYoubrowserForm.GoForwardClick(Sender: TObject);
begin
 //falsch: If GoForwardV = False Then Browser.GoForward;
 If GoForwardV Then Browser.GoForward;
end;


oder gibt es da noch ein anderes Problem?

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: So 01.11.09 12:02 
Ok zu 1^^ ich habe den Fehler selbst gefunden... leichtsinnsfehler...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
case Command of
  CSC_NAVIGATEBACK: GoBackV := Enable;

//Hier habe ich der Variable GoBackV das ergebnis von Forward hinzugefügt^^
//Hier müsste statt GoBackV - GoForwardV stehen... jetz gehts^^
  CSC_NAVIGATEFORWARD: GoBackV := Enable;
  end;


also 1 ist erledigt

aber mit der 2 bekomm ich das einfach nicht hin. Wen ihr nochmal ein Bespiel macht, währe es nett, wenn ihr die Proceduren ungekürzt mitschreiben könntet^^


Danke für 1!!!! Für 2 schon im Vorraus^^
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: So 01.11.09 19:21 
Hallo,

2x GoBackV war mir nicht aufgefallen :(

Wie sieht denn Dein Code zu 2 aus, was bekommst Du da nicht hin, kein Ergebnis?

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Di 03.11.09 15:57 
Ok wie gesagt hab ich noch das Problem mit dem URL ich benutze Turbo Delphi 2006 und habe bei Webbrowwser nur die proceduren:

- OnNavigateComplete2
- OnBeforeNavigate2
- OnNavigateError

und außerdem währe es nett wenn ihr mir noch erklären könntet, was "Application.ProcessMessages" bewirkt^^
Danke schon im Vorraus
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Di 03.11.09 16:47 
Hallo,

was meinst Du mit "nur die proceduren", in Deinem Code?
Und wie hast Du das denn mit OnCommandStateChange und GoBack etc. realisiert, wenn Du nur die von Dir aufgeführten hast. Ich zitiere mal:
user profile iconDelphi2009lover hat folgendes geschrieben Zum zitierten Posting springen:
...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
//...
procedure TYoubrowserForm.BrowserOnCommandChange(ASender: TObject; Command: Integer;
  Enable: WordBool);
//...

...


Markier mal die WebBwrowser-Komponente auf Deiner Form und dann schau mal in den Objekt-Inspektor auf der Registerkarte Ereignisse, da solltest du noch einiges mehr finden.

zu "Application.ProcessMessages"
Ist das so schwer, das mal in die Suche einzugeben :gruebel:
Application.ProcessMessages verarbeitet Messages:
ausblenden Delphi-Quelltext
1:
2:
3:
Browser.Navigate(...);                      //navigieren
while Browser.ReadyState <> READYSTATE_COMPLETE do // solange Bedingung nicht zutrifft 
Application.ProcessMessages;                       // verarbeite ankommende Messages

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )