Everyone who owns a website would have heard about the RSS phenomenon. Now you will get the opportunity to create your own RSS reader that will enable you to download and view RSS files on your desktop. This application will enable you to read RSS feeds from the Internet with the added advantage of being able to download XML files to your local hard drive.
Creating an RSS Reader - Web Browser Code (Page 3 of 4 )
Click on the TWebBrowser component, go to the object inspectors event tab, double click on the CommandStateChange event and add the following code:
procedure TForm1.wbCommandStateChange(Sender: TObject; Command: Integer; Enable: WordBool); begin
case Command of CSC_UPDATECOMMANDS : begin wbRefresh.Enabled := not wb.Busy; end;
CSC_NAVIGATEFORWARD : begin navforward.Enabled := Enable; end;
CSC_NAVIGATEBACK : begin navback.Enabled := Enable; end;
end; end;
The code above enables and disables the browser-related buttons depending on what state the browser is in.
In the object inspector, double click on the OnDocumentComplete event and add the following code:
procedure TForm1.wbDocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); begin wbRefresh.Enabled := true; end;
This procedure just enables the refresh button once the browser has completed downloading a web page.
Next, double click on the OnNewWindow2 event and add the following code:
procedure TForm1.wbNewWindow2(Sender: TObject; var ppDisp: IDispatch; var Cancel: WordBool); var NewWindow : TForm1; begin NewWindow := TForm1.Create(self); with NewWindow do begin ppDisp := wb.Application; show; end; end;
This procedure ensures that any link that you click on opens up a web page in the TWebBrowser component, and not in the default browser of the system.
Next, double click on the OnStatusTextChange event and add the following code:
The code adds browser status text to the Statusbar. For example, if the browser loads a new document, a message stating that action will be displayed in the status bar.