Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / July 2005

Tip: Looking for answers? Try searching our database.

pass parameters back from c/c++ to JScript

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric - 21 Jul 2005 06:42 GMT
Hi, all

I import Microsoft Webbrowser Control to my VC6 MFC project and customize
the web browser with my own doc handler. The following is the implemenation:

ICustomDoc * pCustdoc;
m_WebBrowser.GetDocument()->QueryInterface(&pCustdoc);  // m_WebBrowser is
an instance of Microsoft Webbrowser Control
if (pCustdoc)
{
 pCustdoc->SetUIHandler(m_pDocHandler);  // m_pDocHandler is my doc handler
for the web browser.
 pCustdoc->Release();
}

Then I can call C/C++ functions from  web page JScript, such as:
external.MyFunc("abcdef"). In this way, I can pass parameters from JScript
to C/C++ function. However, in some cases, "MyFunc" may have some return
values. My problem is: how can I pass parameters back from c/c++ function to
JScript?
And, how to call JScript from C/C?

Any idea?

Thanks
Eric
Eric - 21 Jul 2005 08:27 GMT
web page
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/
wbcustomization.asp descripts how to customize theweb browser. And it says
"You can also use this technique to pass whole objects to a page. To do
this, create a method in your IDispatch implementation that passes back the
object you want to make available."<SCRIPT language="JScript">
function MyFunc(iSomeData)
{
   var oCustCalendarObj;
   external.GetCustomCalender(oCustCalenderObj);
   oCustCalerdarObj.doStuffWithIt();
   .
   .
   .
}
</SCRIPT>But how to program in function Invoke? It seems that code like this
won't work:    pDispParams->rgvarg[1].byref = &m_passback; // m_passback is
an object    pDispParams->rgvarg[1].vt = VT_BYREF; //VT_DISPATCH |
//////////////////////////////Prototype of
Invoke/////////////////////////////////////////////////        virtual /*
[local] */ HRESULT STDMETHODCALLTYPE Invoke(             /* [in] */ DISPID
dispIdMember,            /* [in] */ REFIID riid,            /* [in] */ LCID
lcid,            /* [in] */ WORD wFlags,            /* [out][in] */
DISPPARAMS *pDispParams,            /* [out] */ VARIANT *pVarResult,
/* [out] */ EXCEPINFO *pExcepInfo,            /* [out] */ UINT
*puArgErr)//////////////////////////////////////////////////////////////////
//////////////////////////////////////////
> Hi, all
>
[quoted text clipped - 22 lines]
> Thanks
> Eric
Eric - 22 Jul 2005 06:32 GMT
I am in hurry. I hope people who know this can give me help.
Or,  I didn't describe things clear?

> Hi, all
>
[quoted text clipped - 22 lines]
> Thanks
> Eric
Serge Baltic - 22 Jul 2005 18:07 GMT
Hello,

E> My problem is: how can I pass parameters back from c/c++
E> function to JScript?

Obviously, thru a return value of the function ;)

Looks like:

HRESULT MyFunc([in] BSTR What, [in] VARIANT When, [out, retval] BSTR *Result);

— in an IDL file. Here What and When are function arguments, and Result is
a return value. It should be a pointer to the actual return value type (eg
BSTR*, long*, IDispatch**, and so on).

E> And, how to call JScript from C/C?

Hmm. First, you can get the script object from the Web browser control somehow,
probably thru taking its Document property and treating it as a IHTMLDocumentN*
pointer, where N varies. The script object allows to call any of its functions.

The script global variables are also available from the window object properties
(webbrowser.Document.parentWindow, or something like that). Maybe the functions
are also (I have never checked). If yes, then a JScript function is a Function
ActiveX object, that has a call() method to be invoked via late binding.
If no, then you may assign a function to a global variable, to an attribute
of the BODY HTML element, pass it into a C++ function call, and so on, to
give your C++ side an IDispatch* object representing the function. Yep?

If you're using browser interaction intensively, you may even completely
drop the JScript part of the code, as everything can be done right in C++
as well. Subscribe to events, do the things, etc.

(H) Serg

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.