<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/activeqt/control/qaxfactory.cpp:75 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>TQAxFactory Class</title> <style type="text/css"><!-- fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQAxFactory Class Reference<br><small>[<a href="qaxserver.html">TQAxServer module</a>]</small></h1> <p>The TQAxFactory class defines a factory for the creation of COM components. <a href="#details">More...</a> <p>This class is part of the <b>TQt ActiveTQt Extension</b>. <p><tt>#include <<a href="qaxfactory-h.html">qaxfactory.h</a>></tt> <p><a href="qaxfactory-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li class=fn><a href="#TQAxFactory"><b>TQAxFactory</b></a> ( const TQUuid & libid, const TQUuid & appid )</li> <li class=fn>virtual <a href="#~TQAxFactory"><b>~TQAxFactory</b></a> ()</li> <li class=fn>virtual TQStringList <a href="#featureList"><b>featureList</b></a> () const = 0</li> <li class=fn>virtual TQWidget * <a href="#create"><b>create</b></a> ( const TQString & key, TQWidget * parent = 0, const char * name = 0 )</li> <li class=fn>virtual TQObject * <a href="#createObject"><b>createObject</b></a> ( const TQString & key, TQObject * parent = 0, const char * name = 0 )</li> <li class=fn>virtual TQMetaObject * <a href="#metaObject"><b>metaObject</b></a> ( const TQString & key ) const</li> <li class=fn>virtual bool <a href="#createObjectWrapper"><b>createObjectWrapper</b></a> ( TQObject * object, IDispatch ** wrapper )</li> <li class=fn>virtual TQUuid <a href="#classID"><b>classID</b></a> ( const TQString & key ) const</li> <li class=fn>virtual TQUuid <a href="#interfaceID"><b>interfaceID</b></a> ( const TQString & key ) const</li> <li class=fn>virtual TQUuid <a href="#eventsID"><b>eventsID</b></a> ( const TQString & key ) const</li> <li class=fn>virtual TQUuid <a href="#typeLibID"><b>typeLibID</b></a> () const</li> <li class=fn>virtual TQUuid <a href="#appID"><b>appID</b></a> () const</li> <li class=fn>virtual void <a href="#registerClass"><b>registerClass</b></a> ( const TQString & key, TQSettings * settings ) const</li> <li class=fn>virtual void <a href="#unregisterClass"><b>unregisterClass</b></a> ( const TQString & key, TQSettings * settings ) const</li> <li class=fn>virtual bool <a href="#validateLicenseKey"><b>validateLicenseKey</b></a> ( const TQString & key, const TQString & licenseKey ) const</li> <li class=fn>virtual TQString <a href="#exposeToSuperClass"><b>exposeToSuperClass</b></a> ( const TQString & key ) const</li> <li class=fn>virtual bool <a href="#stayTopLevel"><b>stayTopLevel</b></a> ( const TQString & key ) const</li> <li class=fn>virtual bool <a href="#hasStockEvents"><b>hasStockEvents</b></a> ( const TQString & key ) const</li> <li class=fn>virtual bool <a href="#isService"><b>isService</b></a> () const</li> <li class=fn>enum <a href="#ServerType-enum"><b>ServerType</b></a> { SingleInstance, MultipleInstances }</li> </ul> <h2>Static Public Members</h2> <ul> <li class=fn>bool <a href="#isServer"><b>isServer</b></a> ()</li> <li class=fn>TQString <a href="#serverDirPath"><b>serverDirPath</b></a> ()</li> <li class=fn>TQString <a href="#serverFilePath"><b>serverFilePath</b></a> ()</li> <li class=fn>bool <a href="#startServer"><b>startServer</b></a> ( ServerType type = MultipleInstances )</li> <li class=fn>bool <a href="#stopServer"><b>stopServer</b></a> ()</li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> <p> This class is defined in the <b>TQt <a href="activentqt.html#ActiveTQt">ActiveTQt</a> Extension</b>, which can be found in the <tt>qt/extensions</tt> directory. It is not included in the main TQt API. <p> The TQAxFactory class defines a factory for the creation of COM components. <p> <!-- index TQAXFACTORY_DEFAULT --><a name="TQAXFACTORY_DEFAULT"></a><!-- index TQAXFACTORY_EXPORT --><a name="TQAXFACTORY_EXPORT"></a><!-- index TQAXFACTORY_BEGIN --><a name="TQAXFACTORY_BEGIN"></a><!-- index TQAXFACTORY_END --><a name="TQAXFACTORY_END"></a><!-- index TQAXCLASS --><a name="TQAXCLASS"></a> <p> Implement this factory once in your ActiveX server to provide information about the components the server can create. If your server supports just a single ActiveX control, you can use the default factory implementation instead of implementing the factory yourself. Use the <a href="qaxfactory.html#TQAXFACTORY_DEFAULT">TQAXFACTORY_DEFAULT</a> macro in any implementation file (e.g. main.cpp) to instantiate and export the default factory: <p> <pre> #include <<a href="qapplication-h.html">ntqapplication.h</a>> #include <<a href="qaxfactory-h.html">qaxfactory.h</a>> #include "theactivex.h" TQAXFACTORY_DEFAULT( TheActiveX, // widget class "{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID ) </pre> <p> If you implement your own factory reimplement the pure virtual functions, provide the unique identifiers for the ActiveX controls, and use the <a href="qaxfactory.html#TQAXFACTORY_EXPORT">TQAXFACTORY_EXPORT</a> macro to instantiate and export it: <p> <pre> TQStringList ActiveTQtFactory::featureList() const { <a href="ntqstringlist.html">TQStringList</a> list; list << "ActiveX1"; list << "ActiveX2"; ... return list; } TQWidget *ActiveTQtFactory::create( const <a href="ntqstring.html">TQString</a> &key, TQWidget *parent, const char *name ) { if ( key == "ActiveX1" ) return new ActiveX1( parent, name ); if ( key == "ActiveX2" ) return new ActiveX2( parent, name ); ... return 0; } TQUuid ActiveTQtFactory::classID( const <a href="ntqstring.html">TQString</a> &key ) const { if ( key == "ActiveX1" ) return "{01234567-89AB-CDEF-0123-456789ABCDEF}"; ... return TQUuid(); } TQUuid ActiveTQtFactory::interfaceID( const <a href="ntqstring.html">TQString</a> &key ) const { if ( key == "ActiveX1" ) return "{01234567-89AB-CDEF-0123-456789ABCDEF}"; ... return TQUuid(); } TQUuid ActiveTQtFactory::eventsID( const <a href="ntqstring.html">TQString</a> &key ) const { if ( key == "ActiveX1" ) return "{01234567-89AB-CDEF-0123-456789ABCDEF}"; ... return TQUuid(); } TQAXFACTORY_EXPORT( MyFactory, // factory class "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID ) </pre> <p> If you use the <tt>TQ_CLASSINFO</tt> macro to provide the unique identifiers or other attributes for your class you can use the <a href="qaxfactory.html#TQAXFACTORY_BEGIN">TQAXFACTORY_BEGIN</a>, <a href="qaxfactory.html#TQAXCLASS">TQAXCLASS</a> and <a href="qaxfactory.html#TQAXFACTORY_END">TQAXFACTORY_END</a> macros to expose one or more classes as COM objects. <p> <pre> TQAXFACTORY_BEGIN( "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID ) TQAXCLASS(Class1) TQAXCLASS(Class2) TQAXFACTORY_END() </pre> <p> Only one TQAxFactory implementation may be instantiated and exported by an ActiveX server application. This instance is accessible through the global qAxFactory() function. <p> A factory can also reimplement the <a href="#registerClass">registerClass</a>() and <a href="#unregisterClass">unregisterClass</a>() functions to set additional flags for an ActiveX control in the registry. To limit the number of methods or properties a widget class exposes from its parent classes reimplement <a href="#exposeToSuperClass">exposeToSuperClass</a>(). <hr><h2>Member Type Documentation</h2> <h3 class=fn><a name="ServerType-enum"></a>TQAxFactory::ServerType</h3> <p> This enum specifies the different types of servers that can be started with startServer. <ul> <li><tt>TQAxFactory::SingleInstance</tt> - The server can create only one instance of each supplied class. <li><tt>TQAxFactory::MultipleInstances</tt> - The server can create multiple instances of each supplied class. </ul> <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="TQAxFactory"></a>TQAxFactory::TQAxFactory ( const <a href="ntquuid.html">TQUuid</a> & libid, const <a href="ntquuid.html">TQUuid</a> & appid ) </h3> Constructs a TQAxFactory object that returns <em>libid</em> and <em>appid</em> in the implementation of the respective interface functions. <h3 class=fn><a name="~TQAxFactory"></a>TQAxFactory::~TQAxFactory ()<tt> [virtual]</tt> </h3> Destroys the TQAxFactory object. <h3 class=fn><a href="ntquuid.html">TQUuid</a> <a name="appID"></a>TQAxFactory::appID () const<tt> [virtual]</tt> </h3> <p> Reimplement this function to return the ActiveX server's application identifier. <h3 class=fn><a href="ntquuid.html">TQUuid</a> <a name="classID"></a>TQAxFactory::classID ( const <a href="ntqstring.html">TQString</a> & key ) const<tt> [virtual]</tt> </h3> Reimplement this function to return the class identifier for each <em>key</em> returned by the <a href="#featureList">featureList</a>() implementation, or an empty <a href="ntquuid.html">TQUuid</a> if this factory doesn't support the value of <em>key</em>. <p> The default implementation interprets <em>key</em> as the class name, and returns the value of the TQ_CLASSINFO entry "ClassID". <h3 class=fn><a href="ntqwidget.html">TQWidget</a> * <a name="create"></a>TQAxFactory::create ( const <a href="ntqstring.html">TQString</a> & key, <a href="ntqwidget.html">TQWidget</a> * parent = 0, const char * name = 0 )<tt> [virtual]</tt> </h3> Reimplement this function to return a new widget for <em>key</em>. Propagate <em>parent</em> and <em>name</em> to the <a href="ntqwidget.html">TQWidget</a> constructor. Return 0 if this factory doesn't support the value of <em>key</em>. <p> The returned widget will be exposed as an ActiveX control, e.g. a COM object that can be embedded as a control into applications. <p> The default implementation returns 0. <h3 class=fn><a href="ntqobject.html">TQObject</a> * <a name="createObject"></a>TQAxFactory::createObject ( const <a href="ntqstring.html">TQString</a> & key, <a href="ntqobject.html">TQObject</a> * parent = 0, const char * name = 0 )<tt> [virtual]</tt> </h3> Reimplement this function to return a new object for <em>key</em>. Propagate <em>parent</em> and <em>name</em> to the <a href="ntqwidget.html">TQWidget</a> constructor. Return 0 if this factory doesn't support the value of <em>key</em>. <p> If the object returned is a TQWidget it will be exposed as an ActiveX control, otherwise the returned object will be exposed as a COM object. <p> The default implementation returns the result <a href="#create">TQAxFactory::create</a>() if <em>parent</em> is 0 or a widget, otherwise returns 0. <h3 class=fn>bool <a name="createObjectWrapper"></a>TQAxFactory::createObjectWrapper ( <a href="ntqobject.html">TQObject</a> * object, IDispatch ** wrapper )<tt> [virtual]</tt> </h3> <p> Reimplement this function to provide the COM object for <em>object</em> in <em>wrapper</em>. Return TRUE if the function was successfull, otherwise return FALSE. <p> The default implementation creates a generic automation wrapper based on the <a href="metaobjects.html#meta-object">meta object</a> information of <em>object</em>. <h3 class=fn><a href="ntquuid.html">TQUuid</a> <a name="eventsID"></a>TQAxFactory::eventsID ( const <a href="ntqstring.html">TQString</a> & key ) const<tt> [virtual]</tt> </h3> Reimplement this function to return the identifier of the event interface for each <em>key</em> returned by the <a href="#featureList">featureList</a>() implementation, or an empty <a href="ntquuid.html">TQUuid</a> if this factory doesn't support the value of <em>key</em>. <p> The default implementation interprets <em>key</em> as the class name, and returns the value of the TQ_CLASSINFO entry "EventsID". <h3 class=fn><a href="ntqstring.html">TQString</a> <a name="exposeToSuperClass"></a>TQAxFactory::exposeToSuperClass ( const <a href="ntqstring.html">TQString</a> & key ) const<tt> [virtual]</tt> </h3> Reimplement this function to return the name of the super class of <em>key</em> up to which methods and properties should be exposed by the ActiveX control. <p> The default implementation interprets <em>key</em> as the class name, and returns the value of the TQ_CLASSINFO entry "ToSuperClass". If no such value is set the null-string is returned, and the functions and properties of all the super classes including <a href="ntqwidget.html">TQWidget</a> will be exposed. <p> To only expose the functions and properties of the class itself, reimplement this function to return <em>key</em>. <h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="featureList"></a>TQAxFactory::featureList () const<tt> [pure virtual]</tt> </h3> <p> Reimplement this function to return a list of the widgets (class names) supported by this factory. <h3 class=fn>bool <a name="hasStockEvents"></a>TQAxFactory::hasStockEvents ( const <a href="ntqstring.html">TQString</a> & key ) const<tt> [virtual]</tt> </h3> Reimplement this function to return TRUE if the ActiveX control <em>key</em> should support the standard ActiveX events <ul> <li> Click <li> DblClick <li> KeyDown <li> KeyPress <li> KeyUp <li> MouseDown <li> MouseUp <li> MouseMove </ul> <p> The default implementation interprets <em>key</em> as the class name, and returns TRUE if the value of the TQ_CLASSINFO entry "StockEvents" is "yes". Otherwise this function returns FALSE. <h3 class=fn><a href="ntquuid.html">TQUuid</a> <a name="interfaceID"></a>TQAxFactory::interfaceID ( const <a href="ntqstring.html">TQString</a> & key ) const<tt> [virtual]</tt> </h3> Reimplement this function to return the interface identifier for each <em>key</em> returned by the <a href="#featureList">featureList</a>() implementation, or an empty <a href="ntquuid.html">TQUuid</a> if this factory doesn't support the value of <em>key</em>. <p> The default implementation interprets <em>key</em> as the class name, and returns the value of the TQ_CLASSINFO entry "InterfaceID". <h3 class=fn>bool <a name="isServer"></a>TQAxFactory::isServer ()<tt> [static]</tt> </h3> Returns TRUE if the application has been started (by COM) as an ActiveX server, otherwise returns FALSE. <p> <pre> int main( int argc, char**argv ) { <a href="ntqapplication.html">TQApplication</a> app( argc, argv ); if ( !TQAxFactory::isServer() ) { // initialize for stand-alone execution } return app.<a href="ntqapplication.html#exec">exec</a>() // standard event processing } </pre> <h3 class=fn>bool <a name="isService"></a>TQAxFactory::isService () const<tt> [virtual]</tt> </h3> Reimplement this function to return TRUE if the server is running as a persistent service (e.g. an NT service) and should not terminate even when all objects provided have been released. <p> The default implementation returns FALSE. <h3 class=fn><a href="ntqmetaobject.html">TQMetaObject</a> * <a name="metaObject"></a>TQAxFactory::metaObject ( const <a href="ntqstring.html">TQString</a> & key ) const<tt> [virtual]</tt> </h3> Reimplement this function to return the <a href="ntqmetaobject.html">TQMetaObject</a> corresponding to <em>key</em>, or 0 if this factory doesn't support the value of <em>key</em>. <p> The default implementation returns the TQMetaObject for the class <em>key</em>. <h3 class=fn>void <a name="registerClass"></a>TQAxFactory::registerClass ( const <a href="ntqstring.html">TQString</a> & key, <a href="ntqsettings.html">TQSettings</a> * settings ) const<tt> [virtual]</tt> </h3> Registers additional values for the class <em>key</em> in the system registry using the <em>settings</em> object. The standard values have already been registed by the framework, but additional values, e.g. implemented categories, can be added in an implementation of this function. <p> <pre> settings->writeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/.", TQString::null ); </pre> <p> If you reimplement this function you must also reimplement <a href="#unregisterClass">unregisterClass</a>() to remove the additional registry values. <p> <p>See also <a href="ntqsettings.html">TQSettings</a>. <h3 class=fn><a href="ntqstring.html">TQString</a> <a name="serverDirPath"></a>TQAxFactory::serverDirPath ()<tt> [static]</tt> </h3> Returns the directory that contains the server binary. <p> For out-of-process servers this is the same as <a href="ntqapplication.html#applicationDirPath">TQApplication::applicationDirPath</a>(). For in-process servers that function returns the directory that contains the hosting application. <h3 class=fn><a href="ntqstring.html">TQString</a> <a name="serverFilePath"></a>TQAxFactory::serverFilePath ()<tt> [static]</tt> </h3> Returns the file path of the server binary. <p> For out-of-process servers this is the same as <a href="ntqapplication.html#applicationFilePath">TQApplication::applicationFilePath</a>(). For in-process servers that function returns the file path of the hosting application. <h3 class=fn>bool <a name="startServer"></a>TQAxFactory::startServer ( <a href="qaxfactory.html#ServerType-enum">ServerType</a> type = MultipleInstances )<tt> [static]</tt> </h3> <p> Starts the COM server with <em>type</em> and returns TRUE if successful, otherwise returns FALSE. <p> Calling this function if the server is already running (or for an in-process server) does nothing and returns TRUE. <p> The server is started automatically with <em>type</em> set to MultipleUse if the server executable has been started with the <tt>-activex</tt> command line parameter. <h3 class=fn>bool <a name="stayTopLevel"></a>TQAxFactory::stayTopLevel ( const <a href="ntqstring.html">TQString</a> & key ) const<tt> [virtual]</tt> </h3> Reimplement this function to return TRUE if the ActiveX control <em>key</em> should be a top level window, e.g. a dialog. The default implementation returns FALSE. <h3 class=fn>bool <a name="stopServer"></a>TQAxFactory::stopServer ()<tt> [static]</tt> </h3> <p> Stops the COM server and returns TRUE if successful, otherwise returns FALSE. <p> Calling this function if the server is not running (or for an in-process server) does nothing and returns TRUE. <p> Stopping the server will not invalidate existing objects, but no new objects can be created from the existing server process. Usually COM will start a new server process if additional objects are requested. <p> The server is stopped automatically when the main() function returns. <h3 class=fn><a href="ntquuid.html">TQUuid</a> <a name="typeLibID"></a>TQAxFactory::typeLibID () const<tt> [virtual]</tt> </h3> <p> Reimplement this function to return the ActiveX server's type library identifier. <h3 class=fn>void <a name="unregisterClass"></a>TQAxFactory::unregisterClass ( const <a href="ntqstring.html">TQString</a> & key, <a href="ntqsettings.html">TQSettings</a> * settings ) const<tt> [virtual]</tt> </h3> Unregisters any additional values for the class <em>key</em> from the system registry using the <em>settings</em> object. <p> <pre> settings->removeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/." ); </pre> <p> <p>See also <a href="#registerClass">registerClass</a>() and <a href="ntqsettings.html">TQSettings</a>. <h3 class=fn>bool <a name="validateLicenseKey"></a>TQAxFactory::validateLicenseKey ( const <a href="ntqstring.html">TQString</a> & key, const <a href="ntqstring.html">TQString</a> & licenseKey ) const<tt> [virtual]</tt> </h3> Reimplement this function to return TRUE if <em>licenseKey</em> is a valid license for the class <em>key</em>, or if the current machine is licensed. <p> The default implementation returns TRUE if the class <em>key</em> is not licensed (ie. no TQ_CLASSINFO attribute "LicenseKey"), or if <em>licenseKey</em> matches the value of the "LicenseKey" attribute, or if the machine is licensed through a .LIC file with the same filename as this COM server. <!-- eof --> <hr><p> This file is part of the <a href="index.html">TQt toolkit</a>. Copyright © 1995-2007 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2007 <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> <td align=right><div align=right>TQt 3.3.8</div> </table></div></address></body> </html>