How to call the JScript function of the page in the ActiveX control

xiaoxiao2021-03-06  193

StdMethodimp CXXX :: Callscript (BSTR BSTRFUNC, IDISPATCH * PXMLARG)

{

HRESULT HRESULT = E_FAIL;

Idispatch * pdispscript = null;

Idispatch * pdisparg = null;

IF (! m_phtmldoc)

{

Return HRESULT;

}

HRESULT = m_phtmldoc-> get_script (& PDISPScript);

// ccombstr BSTRHTML;

// htmlelement * pele;

// phtmldoc-> get_body (& pele);

// pele-> get_outerhtml (& BSTRHTML);

If (succeeded && pdispscript)

{

Dispid Dispid;

// locale_user_default

HRESULT = PDISPScript-> GetIDSOFNAMES (IID_NULL, & BSTRFUNC, 1, LOCALE_SYSTEM_DEFAULT, & DISPID);

IF (S_ok! = HRESULT)

{

Pdispscript-> release ();

Return HRESULT;

}

EXCEPINFO EXCEPINFO;

Dispparams Dispparams;

MEMSET (& Dispparams, 0, SizeOf Dispparams);

Dispparams.cargs = 1;

Dispparams.Rgvarg = new variant [1];

Dispparams.cnamedargs = 0;

Dispparams.Rgvarg [0] .vt = vt_dispatch;

Dispparams.Rgvarg [0] .pdispval = pxmlarg;

VARIANT VARRESULT;

Uint narger = (uint) -1; // initialize to invalid Arg

HRESULT = PDISPScript-> Invoke (Dispid, IID_NULL, LOCALE_USER_DEFAULT,

DISPATCH_METHOD,

& Dispparams, & VarResult, & Excepinfo, & Narger;

DELETE [] Dispparams.Rgvarg;

}

Return HRESULT;

}

转载请注明原文地址:https://www.9cbs.com/read-128707.html

New Post(0)