|This article describes how I wrote an MFC application to put ASPWire's news feed onto my site. Here it is:|
Their instructions were simple enough: Get the raw news data from a given ASP page (no more than 4 times a day), create an ASP file with the formatted news in it, and #include it on your page. Here's how I did just that.
First, there were a few restrictions. My site is hosted by a local ISP, and the initial idea of writing a COM component to do the work had a few problems. Remember that the component could only get the content no more than 4 times a day. So the component needed to be called by some scheduling service - something my ISP may not want to do.
The component would also need write permissions to a folder on my site so I could write the ASP file, again maybe not a good idea.
The answer was to write an MFC application (an .exe) that runs on my computer. It gets the data, formats it, then FTP's the file to my ISP. I therefore had full control over when the application ran, and could easily debug and modify it as necessary.
Creating the App using the MFC AppWizard.Creating the application is trivial using Visual C++ v6.0.
Use File/New, and select MFC AppWizard (exe) from the Projects tab.
Enter the project name and choose Ok.
Choose Single document. Hit Next.
Use the defaults for Steps 2-5. Next, Next, Next, Next!
On Step 6, choose CHtmlView for the Base class.
Hit Finish, then Ok. You're done!
Let's write a browser!I chose CHtmlView as our base class because it made our app a browser. That wasn't difficult, was it?
Build and run the application (hit Ctrl+F5), and you'll see Microsoft's C++ home page. Let's quickly change it to point to the page on your site where the news will appear - that way when we're finished I can instantly see the results.
In the ClassView double-click on the OnInitialUpdate method in your View class.
Change "http://www.microsoft.com/visualc/" to "http://CoverYourASP.com/"
Check it out with Ctrl+F5.
Part 2: Put some meat in the application...