一个浏览器 URLs 是一个TComboBox用来 输入网址,我做的没有输入网址的地方没有TComboBox
用什么替代urls 得到点击的链接地址procedure TMainForm.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var
NewIndex: Integer;
begin
NewIndex := HistoryList.IndexOf(URL);
if NewIndex = -1 then
begin
{ Remove entries in HistoryList between last address and current address }
if (HistoryIndex >= 0) and (HistoryIndex < HistoryList.Count - 1) then
while HistoryList.Count > HistoryIndex do
HistoryList.Delete(HistoryIndex);
HistoryIndex := HistoryList.Add(URL);
end
else
HistoryIndex := NewIndex;
if UpdateCombo then
begin
UpdateCombo := False;
NewIndex := URLs.Items.IndexOf(URL);
if NewIndex = -1 then
URLs.Items.Insert(0, URL)
else
URLs.Items.Move(NewIndex, 0);
end;
URLs.Text := URL;
Statusbar1.Panels[0].Text := URL;
end;
用什么替代urls 得到点击的链接地址procedure TMainForm.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var
NewIndex: Integer;
begin
NewIndex := HistoryList.IndexOf(URL);
if NewIndex = -1 then
begin
{ Remove entries in HistoryList between last address and current address }
if (HistoryIndex >= 0) and (HistoryIndex < HistoryList.Count - 1) then
while HistoryList.Count > HistoryIndex do
HistoryList.Delete(HistoryIndex);
HistoryIndex := HistoryList.Add(URL);
end
else
HistoryIndex := NewIndex;
if UpdateCombo then
begin
UpdateCombo := False;
NewIndex := URLs.Items.IndexOf(URL);
if NewIndex = -1 then
URLs.Items.Insert(0, URL)
else
URLs.Items.Move(NewIndex, 0);
end;
URLs.Text := URL;
Statusbar1.Panels[0].Text := URL;
end;
附代码 procedure TForm1.FindAddress;
var
Flags: OLEVariant;begin
Flags := 0;
UpdateCombo := True;
WebBrowser1.Navigate(WideString(path), Flags, Flags, Flags, Flags);
end;procedure TForm1.FormCreate(Sender: TObject);begin
HistoryIndex := -1;
HistoryList := TStringList.Create;
path :=GetCurrentDir() + '\222.html';
self.WebBrowser1.Navigate(path);
end;
procedure TForm1.BackClick(Sender: TObject);
begin
path := HistoryList[HistoryIndex - 1];
FindAddress;
end;
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
NewIndex := HistoryList.IndexOf(URL);
if NewIndex = -1 then
begin
{ Remove entries in HistoryList between last address and current address }
if (HistoryIndex >= 0) and (HistoryIndex < HistoryList.Count - 1) then
while HistoryList.Count > HistoryIndex do
HistoryList.Delete(HistoryIndex);
HistoryIndex := HistoryList.Add(URL);
end
else
HistoryIndex := NewIndex;
end;
procedure TForm1.BackActionUpdate(Sender: TObject);
begin
btnBack.Enabled := (NewIndex > 0);end;
哪里调用了?
你觉得WebBrowser1BeforeNavigate2这个过程里,最后是不是该加上
BackActionUpdate(nil);
这一句呢?