🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4821

Re: Java Script Functions in TCppWebBrowser

#4821
From: Mark Finkle
Date: Sun, 19 Dec 2004 23:05
31 lines
1951 bytes
Not sure if this is what you mean, but you can call javascript from C++
using the following code:

    LPDISPATCH document = 0;
    wbBrowser->ControlInterface->get_Document(&document);
    IHTMLDocument* htmlDocument = 0;
    HRESULT hr = document->QueryInterface(IID_IHTMLDocument,
(void**)&htmlDocument);
    if (SUCCEEDED(hr)) {
        DISPID saveID = 0;
        OLECHAR FAR* saveName = L"doSave"; //  Name of the JS function
        LPDISPATCH script = 0;
        htmlDocument->get_Script(&script);
        hr = script->GetIDsOfNames(IID_NULL, &saveName, 1,
LOCALE_SYSTEM_DEFAULT, &saveID);
        if (SUCCEEDED(hr)) {
            // Invoke function
            // I am assuming there are no arguments. Read about
IDispatch::Invoke
            DISPPARAMS noArgs = {NULL, NULL, 0, 0};
            hr = script->Invoke(saveID, IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD, &noArgs, NULL, NULL, NULL);
        }
        script->Release();
        htmlDocument->Release();
    }
    document->Release();


Hope it helps,
Mark Finkle
Technical Details
Message-ID: <41c60956@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41c5fe40$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,a9720944a62da946
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mark Finkle" <mark_finkle@no.spam.hotmail.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <41c5fe40$1@newsgroups.borland.com>
Subject: Re: Java Script Functions in TCppWebBrowser
Date: Sun, 19 Dec 2004 18:05:57 -0500
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
x-mimeole: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 69.162.33.46
Message-ID: <41c60956@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1103497558 69.162.33.46 (19 Dec 2004 15:05:58 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail