Solved

CWebControl PostData

Posted on 1998-07-28
2
367 Views
Last Modified: 2013-11-20
I'm using the following code in a VC++5.0(no patches applied), IE4.01
configuration and postData is not working.  The web browser control
navigates to the url I give it, but it's method is GET and it doesn't send
my postData.  When PostData is not NULL it's supposed to send a
request method of POST and send the data.

Also I sent a breakpoint in BeforeNavigate2() and read the PostData string
it's empty!

Here is the code snippet from my app.

void CMyView::SetNavigationLocation(CString url, CString postData)
{
    //    url = "http://www.ecst.csuchico.edu/~jschlich/Flyfish/fishinfotest.cgi";
   //    postData = "userid=tim_z&pass=dont_you_wish";

    CString header;
    // Content-Type: application/x-www-form-urlencoded\r\n
    header.LoadString(IDS_FORM_URLENCODED);

    COleVariant oleVariant;
    COleVariant urlOleVariant( url );
    COleVariant dataOleVariant( postData );
    COleVariant headerOleVariant( header );

    m_WebBrowser.Navigate2(&urlOleVariant, &oleVariant, &oleVariant, &dataOleVariant, &headerOleVariant);
}

This problem has got me at a complete stand still.  If anyone can help, I will be very
very grateful and acknowledge you as the MFC WebBrowser guru!

Jeff
0
Comment
Question by:NotJeff
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 210 total points
ID: 1319866
The post data specified by PostData is passed as a SAFEARRAY structure. The variant should be of type VT_ARRAY and point to a SAFEARRAY. The SAFEARRAY should be of element type VT_UI1, dimension one, and have an element count equal to the number of bytes of post data. Instead of

COleVariant dataOleVariant(postData);

do the following,

COleSafeArray saPostData;
if (!postData.IsEmpty())
    saPostData.CreateOneDim(VT_UI1, postData.GetLength(), (LPCTSTR)postData);
0
 

Author Comment

by:NotJeff
ID: 1319867
I hereby hail chensu as the web control master!  And at the same time I'd like to poop on Microsofts documentation of this function.  Everything works great now!  Send me an email at the root url in my sample and I'll buy you lunch.  Thanks  NotJeff
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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