Support for Scripting

Any time you run the ATL Simple Object Wizard and choose Dual as the interface type, ATL generates an interface definition for the default interface that derives from IDispatch and is marked with the dual attribute, and places it in the IDL file. Because it derives from IDispatch, our dual interface can be used by scripting clients such as Active Server Pages (ASP), Internet Explorer (IE), and Windows Script Host (WSH). When our COM class supports IDispatch, we can use objects of that class from scripting environments. Here's an example HTML page that uses an instance of the CalcPi object:

<object class         id=objPiCalculator> </object> <script language=vbscript>   ' Set the digits property   objPiCalculator.digits = 5   ' Calculate pi   dim pi   pi = objPiCalculator.CalcPi   ' Tell the world!   document.write "Pi to " & objPiCalculator.digits & _     " digits is " & pi </script> 

For more information about how to handle the inconvenient data types associated with scriptingnamely, BSTRs and VARIANTssee Chapter 2, "Text and Strings," and Chapter 3, "ATL Smart Types."

ATL Internals. Working with ATL 8
ATL Internals: Working with ATL 8 (2nd Edition)
ISBN: 0321159624
EAN: 2147483647
Year: 2004
Pages: 172

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: