🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Clicking an HTMLInputButton with C++Builder

#1291
From: Mitch McInelly
Date: Fri, 25 Feb 2005 22:32
71 lines
3413 bytes
Again, thank you.  It works perfectly!



"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:421f9ac7$1@newsgroups.borland.com...
>
> "Mitch McInelly" <mitch@agencysoftware.com> wrote in message
> news:421f8f60$1@newsgroups.borland.com...
>
>> Now I am trying to get my app to click a submit button on a
>> form after I have prefilled the data.
> <snip>
>> For some reason the button is never found (the ShowMessage
>> never fires).  Am I using the wrong element?
>
> Yes.  Your form is using an image, not a button, so you should be looking
> for IHTMLInputImage rather than IHTMLInputButtonElement.
>
> Rathr than trying to click the submit button, you should instead get the
> IHTMLFormElement interface for the form itself and call its submit() 
> method.
> For example:
>
>    void __fastcall TMain::SubmitForm(void)
>    {
>        TComInterface<IHTMLDocument2> Doc;
>        Browser->Document->QueryInterface(IID_IHTMLDocument2,
> (LPVOID*)&Doc);
>        if( Doc )
>        {
>            TComInterface<IHTMLElementCollection> Forms;
>            Doc->get_forms(&Forms);
>            if( Forms )
>            {
>                long count = 0;
>                Forms->get_length(&count);
>
>                for(long x = 0; x < count; ++x)
>                {
>                    TVariant item = x;
>                    TVariant index = 0;
>                    TComInterface<IDispatch> Disp;
>
>                    Forms->item(item, index, &Disp);
>                    if( Disp )
>                    {
>                        TComInterface<IHTMLFormElement> Form;
>                        Disp->QueryInterface(IID_IHTMLFormElement,
> (LPVOID*)&Form);
>                        if( Form )
>                        {
>                            ShowMessage("Form Found");
>                            Form->submit();
>                            break;
>                        }
>                    }
>                }
>            }
>        }
>
> If the page has multiple forms, it is your own responsibility to make sure
> that you are submitting the proper form.  If the forms have names 
> assigned,
> you can specify the desired name rather than an index when calling
> IHTMLElementCollection::item().
>
>
> Gambit
>
> 
Technical Details
Message-ID: <421fa806$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <421f8f60$1@newsgroups.borland.com> <421f9ac7$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,184c4a7d124f540d
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: <421f8f60$1@newsgroups.borland.com> <421f9ac7$1@newsgroups.borland.com>
Subject: Re: Clicking an HTMLInputButton with C++Builder
Date: Fri, 25 Feb 2005 14:32:21 -0800
Lines: 73
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; Original
NNTP-Posting-Host: 207.88.115.45
Message-ID: <421fa806$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1109370886 207.88.115.45 (25 Feb 2005 14:34:46 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail