Article View: borland.public.cppbuilder.internet.web
Article #234Re: WebBrowser Navigate Post problems!
From: Mischa Simmonds
Date: Thu, 09 Aug 2007 02:03
Date: Thu, 09 Aug 2007 02:03
83 lines
3576 bytes
3576 bytes
Thank you, thank you Remy!
It works!
However, I had to remove the referencing operators (&) from the
Navigate2 function for it to work (no data was being sent at all). Also,
I used "TVariant vFlags = {0};" instead of "TNoParam() ", as I got the
error, "E2064 Cannot initialize 'OleVariant &' with 'TNoParam' " on
compilation.
Here is my final code....
void WebPostData(_di_IWebBrowser2 CppWebBrowser, AnsiString sURL,
AnsiString sPostData)
{
LPSAFEARRAY psa = SafeArrayCreateVector(VT_UI1, 0, sPostData.Length());
if( psa )
{
void *pvdata = NULL;
SafeArrayAccessData(psa, &pvdata);
memcpy(pvdata, sPostData.c_str(), sPostData.Length());
SafeArrayUnaccessData(psa);
TVariant vPostData(psa);
TVariant vFlags = {0}, vTargetFrameName={0};
TVariant vURL=sURL;
TVariant vContentType =
AnsiString("Content-Type:application/x-www-form-urlencoded\r\n");
CppWebBrowser->Navigate2(vURL, vFlags, vTargetFrameName,
vPostData,vContentType);
}
}
Remy Lebeau (TeamB) wrote:
> "Mischa Simmonds" <mischa1.BanSpam@informationdesign.BanSpam.com.au> wrote
> in message news:46b87478$1@newsgroups.borland.com...
>
>
>> My code is something like this...
>>
>
> That code shouldn't even be able to compile, let alone run. Each of the
> parameters of TCppWebBrowser::Navigate2() expect a pointer to a TVariant,
> but you are not constructing any TVariant instances at all. And it is also
> unclear whether you are actually trying to call the
> TCppWebBrowser::Navigate2() method or the IWebBrowser2::Navigate2() method,
> for that matter.
>
> Try this instead:
>
> AnsiString asPostData = "name=Mischa&Country=Australia";
>
> LPSAFEARRAY psa = SafeArrayCreateVector(VT_UI1, 0, asPostData.Length());
> if( psa )
> {
> void *pvdata = NULL;
> SafeArrayAccessData(psa, &pvdata);
> memcpy(pvdata, asPostData.c_str(), asPostData.Length());
> SafeArrayUnaccessData(psa);
>
> TVariant vPostData(psa);
> TVariant vURL = AnsiString("http://www.somewhere.com");
> TVariant vContentType = AnsiString("Content-Type:
> application/x-www-form-urlencoded\r\n");
>
> CppWebBrowser->Navigate2(&vURL, TNoParam(), TNoParam(), &vPostData,
> &vContentType);
> }
>
>
>
>> I have ... also tried to use the ideas expressed in
>> http://dn.codegear.com/en/article/27519 but get the same result.
>>
>
> The code you showed is not doing anything that article says to do.
>
>
> Gambit
>
>
>
Technical Details
Message-ID:
<46ba75fc@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46b87478$1@newsgroups.borland.com> <46b8a9f1$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,f3fb23a392722ed0 X-Google-Attributes: gidfeeec,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 09 Aug 2007 12:03:42 +1000 From: Mischa Simmonds <mischa1.BanSpam@informationdesign.BanSpam.com.au> User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.web Subject: Re: WebBrowser Navigate Post problems! References: <46b87478$1@newsgroups.borland.com> <46b8a9f1$1@newsgroups.borland.com> In-Reply-To: <46b8a9f1$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 121.210.89.123 Message-ID: <46ba75fc@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1186625020 121.210.89.123 (8 Aug 2007 19:03:40 -0700) Lines: 83 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail