Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 4 - Creating an RSS Reader
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Creating an RSS Reader
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2006-08-16

    Table of Contents:
  • Creating an RSS Reader
  • Code
  • Web Browser Code
  • Navigation Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating an RSS Reader - Navigation Code


    (Page 4 of 4 )

    Next we need to write the navigation code for the TWebBrowser component. Double click on the "back" button and add the following code:

    procedure TForm1.navbackClick(Sender: TObject);
    begin
    wb.GoBack;
    end;

    This code enables the browser to go back to whatever page it was on before. Now double click on the "forward" button and add the following code:

    procedure TForm1.navforwardClick(Sender: TObject);
    begin
    wb.GoForward;
    end;

    This code just tells the browser to go to the next page. Now, double click on the  "Home" button and add the following code:

    procedure TForm1.wbHomeClick(Sender: TObject);
    begin
    wb.GoHome;
    end;

    This code takes the browser to the next page. Now, double click on the "Stop" button and add the following code:

    procedure TForm1.SpeedButton6Click(Sender: TObject);
    begin
    wb.Stop;
    end;

    This code stops the browser from executing. Finally double click on the "Refresh" button and add the following code:

    procedure TForm1.wbRefreshClick(Sender: TObject);
    begin
    wb.Refresh;
    end;

    This code refreshes a page to get its updated content. That’s it, we now have a fully functioning web browser that can load, update and display web pages.

    Now we need some way of adding a new RSS link to our links file, so add a new form to the application and save the unit as “addlink.” Add one TEdit and a button. Double click on the button and add the following code:

    procedure TForm2.btnAddFeedClick(Sender: TObject);
    var
    SomeTxtFile : TextFile;
    begin
    if Fileexists('links.txt') then begin
    AssignFile(SomeTxtFile, 'links.txt');
    Append(SomeTxtFile);
    WriteLn(SomeTxtFile, addfeed.text);
    CloseFile(SomeTxtFile);
    if MessageDlg('The link - ' + addfeed.text + ' - has now been added. Would you like to add another link?', mtInformation,[mbYes, mbNo], 0) = mrYes then begin
    addfeed.Clear;
    form1.tv1.Items.Clear;
    form1.Refresh2;
    end
    else begin
    form1.tv1.Items.Clear;
    form1.Refresh2;
    close;
    end;
    end
    else begin
    AssignFile(SomeTxtFile, 'links.txt');
    Rewrite(SomeTxtFile);
    WriteLn(SomeTxtFile, addfeed.text);
    CloseFile(SomeTxtFile);
    if MessageDlg('The link ' + addfeed.text + ' has now been added. ', mtInformation,[mbYes, mbNo], 0) = mrYes then begin
    addfeed.Clear;
    form1.tv1.Items.Clear;
    form1.Refresh2;
    end
    else begin
    form1.tv1.Items.Clear;
    form1.Refresh2;
    close;
    end;
    end;
    end;

    This piece of code just writes the RSS link location to the links file. The very first line after the begin statement checks to see if the links file exists, and if it does, it adds the link that you want to the file. Then you are given the option to add another link. The second section of the code gets executed only if the links file does not exist.

    Now you must be wondering what the Refresh2 procedure does. Well, it reloads the treeview component and updates the links on it. Here’s the code:

    procedure TForm1.refresh2;
    var
    SomeTxtFile : TextFile;
    buffer : string;
    begin
    form1.tv1.Items.Clear;
    //read links from links file   ***********************************
    with form1.tv1.Items.AddFirst(  nil,  'RSS Links'  ) do
    begin
    Selected := true;
    end;
    if fileexists('links.txt')  then begin
    AssignFile(SomeTxtFile, 'links.txt');
    Reset(SomeTxtFile);
    while not EOF(SomeTxtFile) do begin
    ReadLn(SomeTxtFile, buffer);
    with form1.tv1.Items.AddChildFirst(  form1.tv1.Selected,  buffer) do
    begin
    MakeVisible;
    end;
    end;
    CloseFile(SomeTxtFile);
    end;
    end;

    Conclusion

    Here's a suggestion: because a text file is limit in how much data it can store, it would probably be better to store your links in a database, since you will want to add and remove links; also, you might just have a lot of links that you want to store. The text file does not offer the same flexibility as a database would insofar as storage and ease of use is concerned. That’s it for now. The next part will deal with downloading RSS files from the Internet, so that you can view them on your own time. Till then have fun!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    DELPHI-KYLIX ARTICLES

    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT