| | |
newbie needs help, basic mfc stuff
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 0
hello. Sorry for the long post. My ultimate goal is to make a program that can read text off a website, if told the url, when to start reading, and where to stop, and then write the text to a textfile. This is all easy once I am able to read the source code of the html doc given its url. Sooooo... I found this code from Planet Source Code, it claims to be able to read source code of a given url. A couple people responded to it, one person said they couldnt get it to work, another person said it worked great, so I think it probably works. But I am in the camp that cannot get it to work. I make a normal win32 app and in properties i select Use Shared MFC dll. This makes the CString opperations work but the other ones such as CInternetSession do not work, they give me errors of CInternetSession undeclared identifier. I remembered to put in #include <afxinet.h> so i dont understand what is wrong. Can someone please help a newbie??? Here is the code:
edit to add: I am using microsoft visual c++ .net
•
•
•
•
//**************************************
//
#include <afxinet.h>
//**************************************
//
// Name: ^!!~ A better HTML Source Grabb
// er/Stealer ~!!^
// Descriptionimple example of how to
// grab(some people like ti call it 'steal'
// ) the HTML source of a page from a appli
// cation... There are a couple of examples
// here at PSC, but they are not very good
// because they use ReadHuge to store all o
// f the data in a buffer which can cause m
// emory problems, incomplete page sources,
// and of course ugly boxes due to no carri
// age returns or line breaks... This ReadS
// tring version is alot more efficent... I
// t works 100% in MFC... And since this co
// de is so easy to implement into virtuall
// y any project, I am NOT going to post th
// e project files unless I get alot of req
// uests
// By: Zak Farrington
//
// Assumes:Make sure to define m_strURL
// and m_strSource via ClassWizard
//
//This code is copyrighted and has// limited warranties.Please see http://
// www.Planet-Source-Code.com/vb/scripts/Sh
// owCode.asp?txtCodeId=7754&lngWId=3//for details.//**************************************
//
//** Make sure you add two edit boxes to
// your dialog, make the one for the URL in
// put a CString named 'm_strURL'
//** And to store the source add another
// edit box(Make sure its multi line), make
// it a CString named 'm_strSource'
void CYourDialogClass::OnYourEvent()
{
UpdateData(TRUE); //** Perform DDX and get user input
CInternetSession session; //** define our internet session
CInternetFile* pFile = (CInternetFile *)session.OpenURL(m_strURL); //** define our internet file that will hold the source
if(pFile) //** If we can OpenURL(m_strURL)
{
CString string; //** Create a buffer string
while (pFile->ReadString(string) != NULL) //** Read as many string as we can until we run into EOF(End Of File)
{
m_strSource += string; //** Add the string of data we just read
m_strSource += "\r\n"; //** Add a line break to make it look better
}
}
UpdateData(FALSE);
}
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 0
I fixed it by making a new project, still a win32 app, and made it a console project (which is what I normally do) and selected Add MFC support, (which I had done before) and then also clicked Add ATL support.
Can someone explain why adding ATL support made the afxinet class work?
I also had to delete the UpdateData lines. Those didnt make sense anyway.
Can someone explain why adding ATL support made the afxinet class work?
I also had to delete the UpdateData lines. Those didnt make sense anyway.
![]() |
Similar Threads
- Newbie PHP / MySQL Question (PHP)
- windows explorer in mfc (C++)
- newbieproblem with structs and fstream (C++)
- what on earth is MFC (C++)
- MFC File I/O Philosophy questions/clarifications (C++)
- Basic Question (Visual Basic 4 / 5 / 6)
- what OS to use? (Getting Started and Choosing a Distro)
Other Threads in the C++ Forum
- Previous Thread: Visual c++ libraries
- Next Thread: Basic help
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector visualstudio win32 windows winsock word wordfrequency wxwidgets




imple example of how to 
