🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Clicking an HTMLInputButton with C++Builder

#1287
From: Mitch McInelly
Date: Fri, 25 Feb 2005 20:47
71 lines
3351 bytes
I am writing an app that prefills applications on the web with information 
stored in my software.   I now understand that I must use the Microsoft DOM 
to achieve my goals.

Now I am trying to get my app to click a submit button on a form after I 
have prefilled the data.  The HTML for the button looks like...


<TD align=right vAlign=top><input type=image alt=Submit height=17
                        src="images/button_submit.gif"
                        width=42 onClick="submitForm();"></TD>

And my code looks like this (with apologies to Remy):

void __fastcall TMain::PushButton(void)
{
        TComInterface<IHTMLDocument2> Doc;
        Browser->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc);
        if( Doc )
        {
            TComInterface<IHTMLElementCollection> All;
            Doc->get_all(&All);
            if( All )
            {
                long count = 0;
                All->get_length(&count);

                for(long x = 0; x < count; ++x)
                {
                    TVariant item = x;
                    TVariant index = 0;
                    TComInterface<IDispatch> Disp;

                    All->item(item, index, &Disp);
                    if( Disp )
                    {
                        TComInterface<IHTMLInputButtonElement> ButtonInput; 
// I've also tried HTMLButtonElement here..
                        Disp->QueryInterface(IID_IHTMLInputButtonElement,(LPVOID*)&ButtonInput);

                        if( ButtonInput )
                        {ShowMessage("Button Found");

                        // Code goes here to make sure Button is of type 
Submit

                         TComInterface<IHTMLElement> Element;
                         Disp->QueryInterface(IID_IHTMLElement,(LPVOID*)&Element); 
// HTMLInputButtonElement has no click() method so I have to revert 
//   back to HTMLElement???

                         if(Element)
                         {Element->click();}


                        }

                    }
                }

           }
        }

}

For some reason the button is never found (the ShowMessage never fires).  Am 
I using the wrong element?

Thanks for looking.

Mitch McInelly
Technical Details
Message-ID: <421f8f60$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,184c4a7d124f540d,start
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
Subject: Clicking an HTMLInputButton with C++Builder
Date: Fri, 25 Feb 2005 12:47:10 -0800
Lines: 73
Organization: Agency Software, Inc.
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
NNTP-Posting-Host: 207.88.115.45
Message-ID: <421f8f60$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1109364576 207.88.115.45 (25 Feb 2005 12:49:36 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder2.on.meganewsservers.com!meganewsservers.com!textfeed1.on.meganewsservers.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail