Article View: borland.public.cppbuilder.internet.web
Article #235Re: WebBrowser Navigate Post problems!
From: Remy Lebeau (TeamB)
Date: Thu, 09 Aug 2007 02:37
Date: Thu, 09 Aug 2007 02:37
54 lines
2870 bytes
2870 bytes
"Mischa Simmonds" <mischa1.BanSpam@informationdesign.BanSpam.com.au> wrote
in message news:46ba75fc@newsgroups.borland.com...
> However, I had to remove the referencing operators (&) from the
> Navigate2 function for it to work (no data was being sent at all).
You need to use the '&' operator. Navigate2() is expecting pointers:
HRESULT Navigate2(VARIANT *URL, VARIANT *Flags, VARIANT
*TargetFrameName, VARIANT *PostData, VARIANT *Headers);
> I used "TVariant vFlags = {0};" instead of "TNoParam() "
TNoParam() is the proper way to pass an empty variant for an optional
parameter. It initializes a TVariant whose vt member is set to VT_ERROR and
scode member is set to DISP_E_PARAMNOTFOUND. Those values are a requirement
for optional parameters, but you are not doing that in your code.
> I got the error, "E2064 Cannot initialize 'OleVariant &' with 'TNoParam' "
> on compilation.
Navigate2() does not use OleVariant.
> Here is my final code....
Try this instead:
void WebPostData(_di_IWebBrowser2 CppWebBrowser, const AnsiString &sURL,
const 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 = TNoParam();
TVariant vTargetFrameName = TNoParam();
TVariant vURL = sURL;
TVariant vContentType =
> AnsiString("Content-Type:application/x-www-form-urlencoded\r\n");
CppWebBrowser->Navigate2(&vURL, &vFlags, &vTargetFrameName,
&vPostData, &vContentType);
}
}
Gambit
Technical Details
Message-ID:
<46ba7ded@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46b87478$1@newsgroups.borland.com> <46b8a9f1$1@newsgroups.borland.com> <46ba75fc@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 From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.web References: <46b87478$1@newsgroups.borland.com> <46b8a9f1$1@newsgroups.borland.com> <46ba75fc@newsgroups.borland.com> Subject: Re: WebBrowser Navigate Post problems! Date: Wed, 8 Aug 2007 19:37:01 -0700 Lines: 56 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.83.29.61 Message-ID: <46ba7ded@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1186627053 75.83.29.61 (8 Aug 2007 19:37:33 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail