Embedded TcppWebBrowser with GoogleMaps, is there a way to retrieve information it?

This is a discussion on Embedded TcppWebBrowser with GoogleMaps, is there a way to retrieve information it? within the C++ Programming forums, part of the General Programming Boards category; I am working on a program that has GoogleMaps embedded within a TcppWebBrowser object. I have alot of javascript in ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    2

    Embedded TcppWebBrowser with GoogleMaps, is there a way to retrieve information it?

    I am working on a program that has GoogleMaps embedded within a TcppWebBrowser object. I have alot of javascript in the page that it loads and I was wandering if there was any way possible to retrieve information from the Javascript in the webbrowser object and pass it back to my c++ code so that I can use that information?

    I currently have the ability to execute functions in the javascript, I just can't retrieve any information yet.

    Any ideas?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by nlraley View Post
    I have alot of javascript in the page that it loads and I was wandering if there was any way possible to retrieve information from the Javascript in the webbrowser object and pass it back to my c++ code so that I can use that information?
    It's not clear what you are after. Does that mean YOU wrote the javascript in the page and you are trying to figure out how to interact with a server side application? Or that this is js in the GoogleMaps thing and you want to figure out how to interact with it?

    If the later, yeah you can. If the former, you (almost certainly should) already know that so...

    Of course I know nuttiin' bout GoogleMaps so may easily have missed a whole dimension. Ignore me.
    Last edited by MK27; 05-19-2010 at 08:13 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2
    Well, I am currently accessing my Javascript with the following function:
    Code:
    void TMainForm::ExecJS(AnsiString cmd)
    {
        IHTMLDocument2 *doc = NULL;
    	IHTMLWindow2 	*win;
    #ifdef DEBUG_EXEC_JS
        std::ofstream fsOut(DEBUG_EXEC_JS, std::ios::app);
        fsOut << cmd.c_str() << std::endl;
        fsOut.close();
    #endif
        //--------------------------------------------
        if (!MapReady && MapMode != mmGoogleEarth && MapMode != mmGoogleMap)
            return;
        //--------------------------------------------
        if (!wwwGoogle || !wwwGoogle->Document)
            return;
        //--------------------------------------------
        if(SUCCEEDED(wwwGoogle->Document->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&doc)))
        {
            HRESULT hr = doc->get_parentWindow(&win);
            if (SUCCEEDED(hr))
            {
         		VARIANT v;
         		VariantInit(&v);
         		win->execScript( WideString(cmd), NULL, &v );
                VariantClear(&v);
                win->Release();
    		}
       	    doc->Release();
        }
        //---------------------------------------
        //DebugLog(AnsiString(wwwGoogle->LocationURL).c_str());
    }
    This allows me to call the Javascript, which is a TcppWebBrowser that hosts a simple html page with alot of Javascript I have made to access and use GoogleMaps.

    However, as you can see, this is a void function. I can't actually return any information. So far I have been able to pass information to my Javascript, but I haven't been able to find a way to retrieve any information from my Javascript. I basically need to retrieve some information from the GoogleMaps api that is embedded in my Javascript, but I have no idea how to do this.

    I have tried altering the above function to return a value, but as of yet have been unsuccessful.

    Oh, and I'm not using any server side scripting or anything of that matter, so its making things a bit difficult.

    Any ideas?

  4. #4
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Well if JavaScript can access sockets, you could run a small TCP server in your C++ code and pipe the data to/from it that way. I dunno: is there the equivalent of JNI in JavaScript? I have only used it for little MickeyMouse projects and on Android (which being Java was accessible via JNI)...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 06-01-2009, 08:54 PM
  2. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 07:27 PM
  3. Embedded for loop information.
    By nikki19 in forum C++ Programming
    Replies: 1
    Last Post: 11-15-2002, 08:40 AM
  4. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM
  5. How to retrieve information about color mode
    By GaPe in forum C Programming
    Replies: 0
    Last Post: 08-04-2002, 07:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21