🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: VB to C++ Help

#905
From: Remy Lebeau (TeamB)
Date: Thu, 01 Dec 2005 20:11
113 lines
4466 bytes
"Al C" <alanc@jancointernational.com> wrote in message
news:438f2c55$1@newsgroups.borland.com...

> I've never had to try this before and hope someone can help.  I need
> to read the contents of a shopping cart by reading their hidden html
> forms.  I was given the following example in VB.  Could someone
> please help translate?

For example (untested):

    #include <utilcls.h>

    WideString __fastcall GetFormElementValue(IHTMLElementCollection *Coll,
const WideString &FormName, const WideString &ElementName)
    {
        TComInterface<IDispatch> disp;

        OLECHECK(Coll->item(TVariant(FormName), TVariant(0), &disp));
        TComInterface<IHTMLFormElement> form = disp;
        disp.Unbind();

        OLECHECK(form->item(TVariant(ElementName), TVariant(0), &disp));
        TComInterface<IHTMLInputElement> element = disp;

        WideString result;
        OLECHECK(element->get_value(&result));

        return result;
    }



    TComInterface<IHTMLDocument2> mDoc = (IDispatch*)
CppWebBrowser1->Document;

    TComInterface<IHTMLFramesCollection2> frames;
    OLECHECK(mDoc->get_frames(&frames));

    TVariant index = 1;
    TVariant item;
    OLECHECK(frames->item(&index, &item));
    TComInterface<IHTMLWindow2> framewindow = V_DISPATCH(&item);

    TComInterface<IHTMLDocument2> framedoc;
    OLECHECK(framewindow->get_document(&framedoc));

    WideString title;
    OLECHECK(framedoc->get_title(&title));

    if( title == L"Order Review" )
    {
        TComInterface<IHTMLElementCollection> all;
        OLECHECK(framedoc->get_all(&all));

        // you did not say what element type tot_forms actually is,
        // so this is only a guess as to how to get its value...
        WideString temp = GetFormElementValue(all, "frmheader",
"tot_forms");
        long cart_count = StrToIntDef(temp, 0);

        if( cart_count > 0 )
        {
            WideString output;

            for(long i = 1; i <= cart_count; ++i)
            {
                switch( i )
                {
                    case 1:
                    {
                        output = "Cart Details:\r\n";

                        // you did not say what element types carthdr and
cartpart_1
                        // actually are, so this is only a guess as to how
to get their values...
                        output += (GetFormElementValue(all, "frmcarthd_1",
"carthdr") + "\r\n");
                        output += (GetFormElementValue(all, "frmcartdet_1",
"cartpart_1") + "\r\n");

                        ShowMessage(output);
                        break;
                    }

                    case 2:
                    {
                        output = "Cart Details:\r\n";

                        // you did not say what element types carthdr and
cartpart_1
                        // actually are, so this is only a guess as to how
to get their values...
                        output += (GetFormElementValue(all, "frmcarthd_2",
"carthdr") + "\r\n");
                        output += (GetFormElementValue(all, "frmcartdet_2",
"cartpart_1") + "\r\n");

                        ShowMessage(output);
                        break;
                    }
                }
            }
        }
    }


To help address the unknown areas, it would be helpful if you would show the
actual HTML.


Gambit
Technical Details
Message-ID: <438f590c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!atl-c02.usenetserver.com!news.usenetserver.com!atl-c07.usenetserver.com!news.usenetserver.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <438f2c55$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,618a63818ab8b9df
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.web
References: <438f2c55$1@newsgroups.borland.com>
Subject: Re: VB to C++ Help
Date: Thu, 1 Dec 2005 12:11:01 -0800
Lines: 115
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: 68.69.17.41
Message-ID: <438f590c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1133467916 68.69.17.41 (1 Dec 2005 12:11:56 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!atl-c02.usenetserver.com!news.usenetserver.com!atl-c07.usenetserver.com!news.usenetserver.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail