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?