pass parameters back from C/C++ to JScript

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



0
EricLiu1 (17)
7/21/2005 8:14:36 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
792 Views

Similar Articles

[PageSpeed] 31

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)
////////////////////////////////////////////////////////////////////////////
////////////////////////////////


"Eric" <EricLiu@moxrd.com> wrote in message
news:u89o7wcjFHA.576@tk2msftngp13.phx.gbl...
> 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
>
>
>


0
EricLiu1 (17)
7/21/2005 8:19:32 AM
I am in hurry. I hope people who know this can give me help.
Or,  I didn't describe things clear?

"Eric" <EricLiu@moxrd.com> wrote in message
news:u89o7wcjFHA.576@tk2msftngp13.phx.gbl...
> 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
>
>
>


0
EricLiu1 (17)
7/22/2005 5:32:16 AM
"Eric" <EricLiu@moxrd.com> wrote in message
news:OpVnszcjFHA.3348@tk2msftngp13.phx.gbl...
> >
> > 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?

Do you use the DISP_FUNCTION_ID macro to declare your external methods? If
so, it's the next-to-last macro parameter that specifies the return type.

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

IHTMLDocument2::get_Script, IDispatch::GetIDsOfNames, IDispatch::Invoke.

-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
7/22/2005 1:35:46 PM
Reply:

Similar Artilces:

Pass-Through Query problem in access 2007
I have an Access 2007 SQL Pass-Through Query to MS SQL Server 2000 that executes a stored procedure with parameters. The SP just inserts some rows in a table and returns an integer as a return code indicating success or failure. When the "ReturnRecords" property is turned on so the code is returned to the client, it appears that the query runs twice since the table shows twice as many rows inserted than it should. When the "ReturnRecords" property is turned off, the correct number of rows are inserted. This is a strange bug. Any ideas? I'm using an ODBC connection. Th...

Front end/Back End configuration
I've recently been blessed with the budget to impliment an FTP server for my small business. I already have an exchange 2003 server that resides behind my firewall. Currently the only employees who have remote access to email are the ones with Laptops and VPN acess. Since I'm installing an FTP server I figured I may as well enable outlook web access for the rest of the employees who do not have company laptops. My initial thought was to install the fTP/Front End server in my DMZ of my firewall and forward the appropriate ports from firewall to LAN. However in my readings I see t...

C++ question #2
I want to set all the member variables of a C++ object to 0, Can I do memset(this , 0 , sizeof(*this)) in the constructor? >I want to set all the member variables of a C++ object to 0, Can I do >memset(this , 0 , sizeof(*this)) in the constructor? Not generally. If your class is composed of plain old data members only (and has no virtual methods), then you could, but I'd recommend that you initialise each variable (that needs explicitly initialising) individually. Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq ...

Outlook CRM Laptop Client to pass data on active MSCRM form into E
I need to develop a "button" with code-behind in Outlook so that the CRM Outlook Laptop Client that can automatically "pass" all the data on an actively opened MSCRM form (custom entity) into an Excel workbook. I have no problems automating Excel (using VBA) but I know next to nothing about how to make Outlook extract data from all the fields on a currently opened custom entity form window, and to "pass" the field data into an Excel speadsheet. Things that I need to know are: 1) How to determine whether the active MSCRM window is which entity. 2) If the acti...

Moving NEWS Items back into Outlook
Hi All, Using Outlook I invoke the OE Newsreader to read newsgroups (like this one for example). Because the OENR and Outlook appear to be very different and uncoupled applications - how can I move a copy of a news item from the OENR into a folder that is "known" by Outlook so it can be archived by Outlook.. Regards Ron H. ...

I dentifying the furthest digit back
I would like to create a VBA or formula that allows me to go back to specific rows or number of records in the database to locate and list how many records since the last time the farthest back value of the 3 evaluated cell values last occurred. example: ,,,,,,,,,,,,C41 9,,,,6,,,,2 ,,,,,,,,,,,,C47 0,,,,7,,,3 A49 7,,,,4,,,,1 A51 B51 C51 (The evaluated cells) 3,,,,7,,,,2 Therefore, the result would list 7, because from the cell values 3,7,2, #2 was the farthest back, when we manually selected the last 10 odd row records and the last 2 previous even row records of cells A, B and ...

Problems backing up exchange 5.5 public folders with Backup exec v9
I get these errors when I try to brick backup our public folders Backup 0041 -- The job failed with the following error: The directory is invalid. Error : a000fe09 - The directory is invalid. Final error: 0xa000fe09 - The directory is invalid. Final error category: Resource Errors After searching Veritas site and doing any suggested fixes nothing is working. The public folders exist and have not been deleted. Some are hidden, some have nothing in them, some are calendars. It fails on about 40 out of 200 public folders. I can view them when browsing from backup exec, so ...

MSMoney 2007
In MSMoney 2007 Deluxe, When I go to an Income Vs Spending report, I have transactions that don't have assigned categories. When I click on the 'Assign categories' I get a Microsoft Visual C++ Runtime Library - Runtime Error. This happens every time, and on two different computers. Looking at the detailed technical information I see an 0x40000015 out of mscoree.dll. Anyone have any idea how to fix this, or where to get additional help from Microsoft? Thanks Phillip In microsoft.public.money, Phillip wrote: >In MSMoney 2007 Deluxe, When I go to an Income Vs Spending re...

Microsoft Visual C++ 9.0 Express Edition : How to link
Dear Hopefully, I am posting in appropriate place :) I have problem of "linking" in the Microsoft Visual C++ 9.0 Express Edition tool. In Visual C++ 6.0, I linked "alpha.lib and common.lib" with following way: "Project" menu -> "Settings" tab -> "Link" tab -> add "common.lib" and "alpha.lib" But I am not able to do this in Microsoft Visual C++ 9.0 Express Edition. Actually, I already have "alpha.lib" and I know where the "alpha.lib" is. I need to create "common.lib". When I build ...

Backing up or copying mail folders
I have many mesages in my email folders that I want to backup to a CD but I cannot find out how to do it. When I go to "Help" it simply tells me to backup to a floppy but I cannot find a copy key to do this. JBRARE ...

Data changed in the back-up spreadsheet
I saved an excel speadsheet with a different file name and all the number values changed except for the dates. The original sheet had no formulas on it and all the new numbers have a decimal place followed by lots of numbers. I don't need to retrieve the old numbers as I backed it up successfully elsewhere but I don't want this to happen again. Any ideas? My first thought is user error. But I can't think of how this could happen by accident. My second thought was that maybe the original worksheet always had those decimals, but the format of the cell hid them: #,##0. If you ...

Moving from class C to class B ip address scheme, any tips(DC/DNS)
We are about to migrate away from a class C ip structure (192.168.100.x) to class B (http://www.subnet-calculator.com/subnet.php?net_class=B) I was basically planning on coming in on a weekend and going around and changing all static ips to their new class B version.. Our domain is 2008 R2, with two DC's, two DNS and one DHCP.. I was going to create a new scope reflecting this new class.. then deactivate the old dhcp and activate the new one.. having everyone power down friday before leaving, so monday they will get the new class B address.. In changing the ip's on t...

XML Deserialization, C#, .NET 1.1
Hi. I have an xml file that stores application settings. simplified it looks like this : <?xml version="1.0" encoding="utf-8" ?> <theRootClass xmlns="http://xyz.com/abc"> <astring> Hello World!</astring> <anarray> <element>Blue</element> <element>Black</element> <element> Red</element> </anarray> <users> <admin>Administrator</admin> <nonAdmin>Users</nonAdmin> </users> </theRootClass> Now, I...

Convert Date To Time Back To Date
Hi, I know the subject line is too confusing. I didnt know how to explain this so I used what I want. I had some one do some data entry work for me sometime back. Now this guy, used his own brains at added time in the format of MM:DD:YYYY instead of MM/DD/YYYY. Now once that is done, as the field was set to store date, it converted the MM:DD:YYYY to some date, other than the actual one. So I now I have completely new date with me. Now I need to take it back to original date. And I have no clue on how to do it. e.g. Actual Date - 04/08/06 Entered As - 04:08:06 Visible As - 12/30/1899 No...

Money 2004 doesn't list available CD-R/CD-RW to back up to....
In Money 2004, why wouldn't it list an available CD-RW to back up to in the drop down box at Tools/Options/Backup? According to this article in the MS Knowledge Base: http://support.microsoft.com/default.aspx?kbid=265130&Product=mny http://tinyurl.com/4bzoj ....it should list it, and on another machine that I have Money 2004 installed on, it lists the A: and a ZIP drive I have installed as D:, but no CD-RW drive. What am I missing that's keeping these two machines from seeing the CD-R/CD-RW as an available drive to write to? -- bill evans WHEvansIIINO@SPAMcharter.net Ha...

Is there a way to unload the loaded XLL file in Excel? Hi all, I am debugging XLL link library using Visual C++. Everytime I rebuild the XLL, I have to close the whole Excel program and relaunch t
Is there a way to unload the loaded XLL file in Excel? Hi all, I am debugging XLL link library using Visual C++. Everytime I rebuild the XLL, I have to close the whole Excel program and relaunch the Excel program again, and then load in the newly generated XLL library again... This is tedious... I am looking for a way to unload XLL (already loaded) from within EXCEL program... Any thoughts? (I find just close the currently active worksheet doesn't get the XLL unloaded...) ...

How do I get my legit MS Money back?
Several months ago I bought and installed MS Money. I had been working along OK until I had PC issues this week. I had to reformat and reinstall everything. I tried reinstalling the MS Money Webinst.exe that I saved, but it keeps telling me that it is a trial version and will not install. I am a legitimate owner of an MS Money license. I am looking for my receipts but cannot seem to find them. But I can verify my identity and the fact that I purchased it if I can find the right person or website to contact. As a MOF I believe I made the purchase signed in with my passport account. This...

Go back to created sheet
This macro creates a new sheet, lets call it "sheet1" to insert a pivot table. Then it returns to the data sheet, let's call it "main" ,does clean up, then stops. Since the new sheet, sheet1, may have different names all the time, ie. sheet2, sheet3, etc.. How can I get the macro to go back to the new sheet? I need the code set up. Also, at what code location do I insert the screenupdate=false to stop it from flashing the screen? Thanks. Post your code for comments "Mercury" <pulgaron@bellsouth.net> wrote in message news:OEDfb.2$Sn1.1@bignews4.bells...

Parameters keep repeating
I have created a graph report . When I ask for the report from the switchboard, I have to enter the date parameter associated with the query more than once. I have to also enter the day again before I print. And if I cancel. it prints a blank report. Is there a way I can view the report, enter the dates, and print without repeated requests. I have battle with this for months. I did try creating a form to associate with it and this still happens -- Thanks, Linda IMHO, parameter prompts in queries are not good user interface http://www.tek-tips.com/faqs.cfm?fid=6763. Consider creating...

isv integration
I just want to confirm that this is not possible. In isv integration scenario for a nav bar or a menu bar item, passing extra parameters via querystring seems unsupported. For example, <NavBarItem Icon="/_imgs/ico_18_sales.gif" Title="Hellow World" Url="/Test/HelloWorld.aspx?customparm=2" PassParams="1" Id="HelloWorld"/> HelloWorld.aspx ends up not getting oId and oType params that it's expecting. The only workaround that I can think of, would be to utilize path rewrite but I'd rather not if I don't have to. Does anyone h...

CRM 3.0 Reports Parameter Passing
Hello All, I'm trying to create a report that looks up values based on the AccountID. How do I pass the accountID into the report? Do I create a parameter named 'CRM_AccocuntID?' Thanks, Caleb Skinner Ascentium ...

POP3 Connector passing external To: addresses back to Exchange
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hiya, Although I've got some Exchange experience, I don't currently have a test rig to find this out for myself, and have had difficulty finding specific information for this particular problem/set-up. Neither do I have access to any affected servers to try a solution (doh). I am trying to assist various businesses who (along with myself) received a newsletter from a mutual supplier. This supplier accidentally put all of the email addresses in the To: field (Not Cc or Bcc) and out of the x00 recipients, eight or nine servers which are ru...

selecting and inserting existing and non existing rows into table parameters and variables
I need to do the following: 1. Select all rows that exist both in the TVP @Headlines and in the table [Headlines].[Headlines] and insert them into a table variable @ExistingHeadlines. 2. Select the rows that exist only in the TVP @Headlines and not in [Headlines].[Headlines] and insert them into a table variable @NonexistentHeadlines. How would you do this? The stored procedure takes 2 totally different paths depending on whether or not the items in @Headlines already exist in the main Headlines table. 1. If they exist already, return an error telling the client that thes...

Money 2005 won't restore back up file.
I run XP and have recently had to reload Money 2005 Premium and then tried to restore my back up file with no success. The back up file was created with the updated (by Microsoft) 2005 programme hence the the reloaded original Money 2005 programme will not restore the back up file and the usual error message appears. I am unable to update my original Money 2005 programme as Microsoft have stopped supporting this version as of last January according to their website. Is there a way round this problem or is there an updated version of Money 2005 Premium available out there for sale? Fai...

Recurrent problem with SEARCH--terminates with a C++ Runtime error
When I run Windows Search, it will almost always terminate with a Runtime Error! Microsoft Visual C++ Runtime Library Program: C:\Windows\Explorer.EXE This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. When I close that box, my desktop goes away (icons, task bar), although I can continue with whatever windows are open until I am finished, then I need to reboot. Does anyone know what may be causing this error? Thanks Ken K Ken wrote: > When I run Windows Search, it...