🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1415

Re: TCppWebBrower AutoFill functionality

#1415
From: Mitch McInelly
Date: Fri, 11 Feb 2005 16:50
112 lines
4564 bytes
Hello Hans,

Thanks you so much for your response.  I have lot's of desktop experience 
but no web experience.  I apologize for being a neophyte.

Maybe my assumptions are wrong.  I am trying to insert a value into a  field 
on an existing web page.  The only way I know to do this is by somehow 
changing the html from, say:

<input  class="frmfld" type="text" name="realname" size="40">
to <input  class="frmfld" type="text" name="realname" value="Mitch McInelly" 
size="40">

I realize that Google's Autofill doesn't do this as the HTML doesn't change 
after the form is filled.  I don't know how they are doing it.  These are 
not my web pages, they are application pages for insurance companies, so I 
can't use Javascript to populate the pages - as I understand it.

Using Adam Vieweger/s article "How to post data using TCppWebBrowser in 
C++Builder".
http://community.borland.com/article/0,1410,27519,00.html (which you have 
referenced in this forum) results in the following code in my application:


void __fastcall TMain::WebPostData(TCppWebBrowser *CppWebBrowser, String 
sURL, String sPostData)
{

  BSTR bstrHeaders = NULL;
  TVariant vFlags = {0}, vTargetFrameName={0}, vPostData={0}, vHeaders={0};
  LPSAFEARRAY psa;
  LPCTSTR cszPostData = sPostData.c_str();
  UINT cElems = lstrlen(cszPostData);
  LPSTR pPostData;
  LPVARIANT pvPostData;

  bstrHeaders = SysAllocString(L"Content-Type: 
application/x-www-form-urlencodedrn");
  if (!bstrHeaders){
    Application->MessageBox("Could not allocate bstrHeaders", "Warning", 
MB_OK | MB_ICONWARNING);
    return;
  }

  V_VT(&vHeaders) = VT_BSTR;
  V_BSTR(&vHeaders) = bstrHeaders;

  pvPostData = vPostData;

  if(pvPostData){
    VariantInit(pvPostData);

    psa = SafeArrayCreateVector(VT_UI1, 0, cElems);
    if(!psa){
      return;
    }

    SafeArrayAccessData(psa, (LPVOID*)&pPostData);
    memcpy(pPostData, cszPostData, cElems);
    SafeArrayUnaccessData(psa);

    V_VT(pvPostData) = VT_ARRAY | VT_UI1;
    V_ARRAY(pvPostData) = psa;
  }

WebBrowser->Navigate2((TVariant)sURL, &vFlags, &vTargetFrameName, 
&vPostData, &vHeaders);

}

which I am calling with:

WebPostData(myBrowser,"http://www.agencysoftware.com/demos.shtml","action=Submit&realname=Mitch");

This doesn't do anything but display the web page with blank fields.  Even 
if it did, I don't always want to push the Submit button - just populate the 
fields for the user.

If you would be intersted in possibly working as a consultant for me on this 
project, please email me directly at mitch@agencysoftware.com

Thank you for your time.

Mitch McInelly



"Hans Galema" <notused@notused.nl> wrote in message 
news:420ccfcb@newsgroups.borland.com...
> Mitch McInelly wrote:
>> I'm trying to add a function to my app that mimics the Google toolbar 
>> AutoFill functionality
>
>> I've tried scraping the web page into a memo, changing the "value=" 
>> properties of the fields,
>
> What have both things to do with each other ?
>
>> and then sending back to the browser.  This doesn't work because the 
>> document then looses site of where it came from (it thinks it's at 
>> about:blank) and the only way I can get back is to Navigate there - which 
>> looses my changes.
>
> You know that javascript can change 'values' ?
>
>> I've tried implementing Adam's code but it doesn't appear to work for me.
>
> Which code ? Adam's code ?
>
> Please explain why an autofill should change values.
>
> Hans. 
Technical Details
Message-ID: <420ce2c9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <420cc1f5@newsgroups.borland.com> <420ccfcb@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,f1eac53c40f0896b
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Mitch McInelly" <mitch@agencysoftware.com>
From: "Mitch McInelly" <mitch@agencysoftware.com>
Newsgroups: borland.public.cppbuilder.internet.web
References: <420cc1f5@newsgroups.borland.com> <420ccfcb@newsgroups.borland.com>
Subject: Re: TCppWebBrower AutoFill functionality
Date: Fri, 11 Feb 2005 08:50:03 -0800
Lines: 114
Organization: Agency Software, Inc.
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 207.88.115.45
Message-ID: <420ce2c9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1108140745 207.88.115.45 (11 Feb 2005 08:52:25 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail