ATLÓëJavaScript½»»¥
ÔÌûµØÖ·£ºhttp://www.followman.com/bbs/Topic-B11-T262.aspx
JavaScript¶¯Ì¬ÏìÓ¦ATLʼþ
Ïà¹ØÌÖÂÛ:http://topic.csdn.net/t/20061012/21/5078729.html
ÖØ
µã£º½Å±¾´«¹ýÀ´µÄ¶ÔÏóÊÇIDispatch½Ó¿Ú£¬Ó¦¸ÃÓÃIDispatch::InvokeÀ´µ÷Óá£Èç¹û´«¹ýÀ´µÄÊǸöfunction£¬ÄÇôDISPID
Ϊ0£¬Èç¹ûÊǸö¶ÔÏó£¬ÄÇôҪÏÈÓÃGetIDsOfNamesµÃµ½DISPID£¬ÔÙInvoke¡£
Ïà¹ØÌÖÂÛ2:http://topic.csdn.net/u/20080418/12/3c09eb2c-fbb4-419f-8a6e-50d78ba8ff2d.html
¿Ø¼þҪʵÏÖʼþÀ´µ÷ÓÃJS½Å±¾£¬Ó¦¸ÃʹÓÃÊôÐÔ£¬ÒòΪJSÓïÑÔ±¾Éí²¢²»Ö§³ÖÁ¬½Óµã¡£¼ÙÉèÄãµÄ¿Ø¼þÊÇICtrl£¬ÒªÌí¼ÓÒ»¸öFirstEventʼþ£¬
ÏñÏÂÃæÕâÑù×ö£º
IDL£º
[propput]HRESULT FirstEvent(VARIANT* pEvent);
.h:
class CCtrl : public ICtrl
{
__stdcall HRESULT
put_FirstEvent(VARIANT* pEvent);
CComQIPtr <IDispatch>
m_spEvent;
void Fire_FirstEvent(VARIANT sType, VARIANT Msg);
}
.cpp:
HRESULT __stdcall CCtrl::put_FirstEvent(VARIANT*
pEvent)
{
assert(pEvent->vt == VT_DISPATCH);
m_spEvent = V_DISPATCH(pEvent);
return S_OK;
}
void
CCtrl::Fire_FirstEvent(VARIANT sType, VARIANT Msg)
{
if
(m_spEvent)
{
CComVariant args[2] = {sType, Msg};
DISPPARAMS dp = {args, NULL, 2, 0};
m_spEvent->Invoke(0,
IID_NULL, LOCALE_USE_DEFAULT, DISPATCH_METHOD, &dp, NULL, NULL,
NULL);
}
}
³É¹¦ÊµÀý:
IDL²¿·Ö:
[propget, id(2), helpstring("ÊôÐÔ OnShowText")]
HRESULT OnShowText([out, retval] IDispatchEx** pVal);
[propput,
id(2), helpstring("ÊôÐÔ OnShowText")] HRESULT OnShowText([in] IDispatchEx*
newVal);
JS²¿·Ö:
function
CreateATL()
{
this
.vv
=
"
ok
"
;
m
=
new
ActiveXObject(
"
ATLPro.AControl
"
);
m.OnShowText
=
function
()
//
OnShowText ÔÚATLÖÐÊÇÒ»¸ö IDispatchEx ¶ÔÏó
{
 
Ïà¹ØÎĵµ£º
ÕýÔò±í´ïʽÊÇÒ»¸ö·Ç³£·Ç³£·Ç³£Ç¿´óµÄÓïÑÔ£¬ÕâÀïÁ¬ÐøÓÃÁËÈý¸ö·Ç³££¬ÎÒ¾õµÃ»¹²»¹»£¬Ëü½¿Ð¡µ«È´¹¦
ÄÜÇ¿´ó£¬¾ø¶ÔµÄŨËõµÄ¾ÍÊǾ«»ª£¬ÎÒ·¢ÏÖÎÒÔ½À´Ô½Ï²»¶ËüÁË¡£
Õâ¶Îʱ¼ä×öÈͮ򵀫¦Àí£¬ÐèÒªÓõ½ÈÕÆÚµÄ¼ÆË㣬°üÀ¨¼Ó¼õʲôµÄ£¬ÓÚÊÇ×öÁËÒ»¸ö¹«Óô¦ÀíµÄÀ©Õ¹£¬½Ð
String.prototype.dateExpression¡£ÒòΪÈÕÆÚ´¦Àí¶¼»áÓõ½±í´ïʽ£¬À ......
ÕâÁ½ÌìÔÚ×öÒ»¸ö¿Ø¼þµÄʱºòÓöµ½Òª´¥·¢onchangeʼþµÄÎÊÌ⣬±¾À´ÒÔΪֵһµ©¸ü¸Ä¾Í»á´¥·¢onchangeʼþ£¬µ«Êµ¼ÊÉϲ»ÊÇÏëÏóÖеÄÄÇÑù¡£
¶ÔÓÚonBlurºÍonFocus¿ÉÒÔÖ±½Óµ÷ÓÃobject.Blur()ºÍobject.Focus()£¬µ«javascriptÖÐûÓÐobject.Changeʼþ¡£ÓÚÊǾÍÔÚÍøÉϲéÁËһϣ¬·¢ÏÖobject.fireEvent()¿ÉÒÔ´¥·¢Ê¼þ£¬Èç´¥·¢onchangeʼþÔòÊ ......
<html>
<body>
<mce:script language=javascript><!--
todayDate = new Date();
date = todayDate.getDate();
month= todayDate.getMonth() +1;
year= todayDate.getYear();
document.write("½ñÌìÊÇ")
document.write("<br>")
if(navigator.appName == "Netscape")
{
document.w ......
window.onload= someFunction();//Ò³Ãæ±¨ÉÐδʵÏÖ´íÎóʱ²»·ÀÓÃÏÂÃæµÄÊÔÒ»ÏÂ
window.onload = someFunction;
window.onload = function (){someFunction();};
window.onload = Function("someFunction();"); ......