?
Solved

Downloading from web page: status callback

Posted on 2000-02-05
4
Medium Priority
?
390 Views
Last Modified: 2013-11-20
My question is a simple one.  How can I get the "!" point to be displayed in the OnStatusCallback function?  I would think that the "!" would be printed a bunch before the code was displayed.  The ! is not displayed at all.

// Global functions
CString Read (CHttpFile *file);

// Classes
class CInternetSession2 : public CInternetSession
{ void OnStatusCallback (DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
};

void CInternetSession2::OnStatusCallback (DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
{ printf ("\r\n\r\n!\r\n\r\n"); // Doesn't display this, ever.
}

int _tmain (int argc, TCHAR* argv[], TCHAR* envp[])
{ if (!AfxWinInit (::GetModuleHandle (NULL), NULL, ::GetCommandLine (), 0))
  { printf ("Fatal Error: MFC initialization failed.");
    return 1;
  }

  CInternetSession2 session;
  CHttpFile *file;

  file = (CHttpFile *) session.OpenURL ("http://etc", 1);

  CString data = Read (file);
  printf (data);

  session.Close ();

  return 0;
}

// Reads all data from a CHttpFile, and then closes and deletes the file.
CString Read (CHttpFile *file)
{ CString ret;

  char data[2];
  int numbytes;

  for (;;)
  { memset (data, 0, 2);

    numbytes = file->Read (data, 1);
    data[numbytes] = 0; // VERY important.
    ret += data;

    if (numbytes == 0)
    { break; }
  }

  file->Close ();
  delete file;

  return ret;
}
0
Comment
Question by:joeshmo
  • 2
  • 2
4 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 2493272
Are you sure that CInternetSession2::OnStatusCallback is even getting called?
0
 

Author Comment

by:joeshmo
ID: 2493304
That's probably part of the question.  I strongly doubt it's even being called.  The code for the web pages print out to the screen without a problem.  There are no exclamation marks however.

Why isn't it being called?  How can I get it to be called?
0
 
LVL 32

Accepted Solution

by:
jhance earned 400 total points
ID: 2493392
Where are you calling EnableStatusCallback()?  I don't see it here.
0
 

Author Comment

by:joeshmo
ID: 2494258
That was what the problem was.  I must have forgotten to add it because I knew it was necessary.  Oops.  Thanks for your help!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question