ActiveX controls implementation differences in VB6 & python using win32com. -


i have third party activex controls designed used in vb6. want migrate controls python. got win32com , ran 'makepy.py -i' on type library file. understand how dispatch executable container using win32com.client.dispatch() method , call subclasses. container called sterling , running when calls object made, don't exclusively mention container in vb code, figure it's not needed here either. have comm objects type library, however, seems work in vb6. vb6 code works , accesses com object after add reference sterling.tlb type library:

' declare activex type library class public withevents m_stiquote stiquote  private sub form_load() ......................................     ' create instance of type library class       set m_stiquote = new stiquote ......................................  end sub  private sub form_unload(cancel integer) ......................................     ' destroy type library class     set m_stiquote = nothing ...................................... end sub  private sub btnmdx_click()     ' structstimdxregex structure comes activex type library     dim inmdxinfo structstimdxregex     inmdxinfo.bstrexchanges = "n"     inmdxinfo.bstrmsgtypes = ""     inmdxinfo.breg = true     inmdxinfo.ballsyms = true     inmdxinfo.bnewonly = false      'call method in activex class structure provided input     m_stiquote.registermdxex inmdxinfo end sub  ' event handler provided library receives class data argument.  private sub m_stiquote_onstiquoteupdate(structquoteupdate sterlinglib.structstiquoteupdate)     logmsg "mdx|" & structquoteupdate.bstrsymbol & "|" & structquoteupdate.nmdxmsgtype end sub 

this have in python far, , can't find _istiquoteevents class , structures record map:

import win32com.client win32com.client import gencache gencache.ensuremodule('{c418adda-61cc-4854-b69e-87f8bf6d7a0e}', 0, 1, 0)  class myquoteevents(_istiquoteevents):     def onstiquoteupdate(self, structquoteupdate=defaultnamednotoptarg):         print_str = "mdx|" + structquoteupdate.bstrsymbol + "|" + structquoteupdate.nmdxmsgtype         print print_str  myquote = win32com.client.dispatchwithevents("stiquote.stiquote_ctrl.1", myquoteevents)  inmdxinfo = structstimdxregex() inmdxinfo.bstrexchanges = "n" inmdxinfo.bstrmsgtypes = "" inmdxinfo.breg = true inmdxinfo.ballsyms = true inmdxinfo.bnewonly = false  myquote.registermdxex(inmdxinfo) 

_istiquoteevents class in makepy generated wrapper, reason it's not visible in script. called gencache, thought should able see it, name not recognized. istiquote class derived dispatchbaseclass, , interface class. stiquote coclassbaseclass derived class in wrapper, , contains istiquote interface & _istiquoteevents events. container app third party program running on machine, code executed when container running. in comm terminology sterling. should sterling. stiquote sub class of sterling. both structquoteupdate , structstimdxregex have recordmap entries clsid, know fields contain vb6 environment. wondering how can extract them wrapper access data structures.

this python wrapper relevant info left makepy.py:

# -*- coding: mbcs -*- # created makepy.py version 0.5.01 # python version 2.7.10 (default, may 23 2015, 09:40:32) [msc v.1500 32 bit (intel)] # type library 'sterling.tlb' # on tue jun 02 17:08:01 2015 'sterling 1.0 type library' makepy_version = '0.5.01' python_version = 0x2070af0  import win32com.client.clsidtoclass, pythoncom, pywintypes import win32com.client.util pywintypes import iid win32com.client import dispatch  # following 3 lines may need tweaking particular server # candidates pythoncom.missing, .empty , .argnotfound defaultnamedoptarg=pythoncom.empty defaultnamednotoptarg=pythoncom.empty defaultunnamedarg=pythoncom.empty  clsid = iid('{c418adda-61cc-4854-b69e-87f8bf6d7a0e}') majorversion = 1 minorversion = 0 libraryflags = 8 lcid = 0x0  .......................................................  win32com.client import dispatchbaseclass  .......................................................  class istiquote(dispatchbaseclass):     'istiquote interface'     clsid = iid('{f8d282cc-fee7-45ec-a080-4276e43e8214}')     coclass_clsid = iid('{8eb74552-c174-4d51-819b-9e65a8916273}')  .......................................................     def registermdxex(self, pmdx=defaultnamednotoptarg):         'method registermdxex'         return self._oleobj_.invoketypes(27, lcid, 1, (24, 0), ((36, 1),),pmdx             )      def registerquote(self, bstrsymbol=defaultnamednotoptarg, bstrexch=defaultnamednotoptarg):         'method registerquote'         return self._oleobj_.invoketypes(1, lcid, 1, (24, 0), ((8, 1), (8, 1)),bstrsymbol             , bstrexch)  ..........................................................................      _prop_map_get_ = {         "askprice": (11, 2, (5, 0), (), "askprice", none),         "asksize": (13, 2, (3, 0), (), "asksize", none),         "bidprice": (10, 2, (5, 0), (), "bidprice", none),         "bidsize": (12, 2, (3, 0), (), "bidsize", none),         "defaultacct": (17, 2, (8, 0), (), "defaultacct", none),         "defaultdest": (19, 2, (8, 0), (), "defaultdest", none),         "defaultqty": (16, 2, (3, 0), (), "defaultqty", none),         "exch": (9, 2, (8, 0), (), "exch", none),         "lastprice": (14, 2, (5, 0), (), "lastprice", none),         "lastsize": (20, 2, (3, 0), (), "lastsize", none),         "level": (21, 2, (3, 0), (), "level", none),         "symbol": (8, 2, (8, 0), (), "symbol", none),         "updateid": (26, 2, (3, 0), (), "updateid", none),     }     _prop_map_put_ = {         "askprice": ((11, lcid, 4, 0),()),         "asksize": ((13, lcid, 4, 0),()),         "bidprice": ((10, lcid, 4, 0),()),         "bidsize": ((12, lcid, 4, 0),()),         "defaultacct": ((17, lcid, 4, 0),()),         "defaultdest": ((19, lcid, 4, 0),()),         "defaultqty": ((16, lcid, 4, 0),()),         "exch": ((9, lcid, 4, 0),()),         "lastprice": ((14, lcid, 4, 0),()),         "lastsize": ((20, lcid, 4, 0),()),         "level": ((21, lcid, 4, 0),()),         "symbol": ((8, lcid, 4, 0),()),         "updateid": ((26, lcid, 4, 0),()),     }     def __iter__(self):         "return python iterator object"         try:             ob = self._oleobj_.invoketypes(-4,lcid,3,(13, 10),())         except pythoncom.error:             raise typeerror("this object not support enumeration")         return win32com.client.util.iterator(ob, none)  ..........................................................................  class _istiquoteevents:     '_istiquoteevents interface'     clsid = clsid_sink = iid('{7482011f-7414-460b-92a8-693f1fdb8c27}')     coclass_clsid = iid('{8eb74552-c174-4d51-819b-9e65a8916273}')     _public_methods_ = [] # com server support     _dispid_to_func_ = {                14 : "onstil2reply",                 1 : "onstiquoteupdate",                 9 : "onstiquoterqstxml",                15 : "onstil2replyxml",                 7 : "onstiquoteupdatexml",                13 : "onstil2updatexml",                 4 : "onstiquoterqst",                12 : "onstil2update",                 3 : "onstishutdown",                 8 : "onstiquotesnapxml",                11 : "onstinewsupdatexml",                10 : "onstigreeksupdatexml",                 5 : "onstigreeksupdate",                 2 : "onstiquotesnap",                 6 : "onstinewsupdate",         }      def __init__(self, oobj = none):         if oobj none:             self._olecp = none         else:             import win32com.server.util             win32com.server.policy import eventhandlerpolicy             cpc=oobj._oleobj_.queryinterface(pythoncom.iid_iconnectionpointcontainer)             cp=cpc.findconnectionpoint(self.clsid_sink)             cookie=cp.advise(win32com.server.util.wrap(self, usepolicy=eventhandlerpolicy))             self._olecp,self._olecp_cookie = cp,cookie     def __del__(self):         try:             self.close()         except pythoncom.com_error:             pass     def close(self):         if self._olecp not none:             cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,none,none             cp.unadvise(cookie)     def _query_interface_(self, iid):         import win32com.server.util         if iid==self.clsid_sink: return win32com.server.util.wrap(self)      # event handlers     # if create handlers, should have following prototypes: #   def onstil2reply(self, arrayl2update=defaultnamednotoptarg): #       'method onstil2replystruct' #   def onstiquoteupdate(self, structquoteupdate=defaultnamednotoptarg): #       'method onstiquoteupdatestruct' #   def onstiquoterqstxml(self, bstrquote=defaultnamednotoptarg): #       'method onstiquoterqstxml' #   def onstil2replyxml(self, bstrquote=defaultnamednotoptarg): #       'method onstil2replyxml' #   def onstiquoteupdatexml(self, bstrquote=defaultnamednotoptarg): #       'method onstiquoteupdatexml' #   def onstil2updatexml(self, bstrquote=defaultnamednotoptarg): #       'method onstil2updatexml' #   def onstiquoterqst(self, structquoterqst=defaultnamednotoptarg): #       'method onstiquoterqststruct' #   def onstil2update(self, structl2update=defaultnamednotoptarg): #       'method onstil2updatestruct' #   def onstishutdown(self): #       'method onstishutdownstruct' #   def onstiquotesnapxml(self, bstrquote=defaultnamednotoptarg): #       'method onstiquotesnapxml' #   def onstinewsupdatexml(self, bstrquote=defaultnamednotoptarg): #       'method onstinewsupdatexml' #   def onstigreeksupdatexml(self, bstrquote=defaultnamednotoptarg): #       'method onstigreeksupdatexml' #   def onstigreeksupdate(self, structgreeksupdate=defaultnamednotoptarg): #       'method onstigreeksupdatestruct' #   def onstiquotesnap(self, structquotesnap=defaultnamednotoptarg): #       'method onstiquotesnapstruct' #   def onstinewsupdate(self, structnewsupdate=defaultnamednotoptarg): #       'method onstinewsupdatestruct'  ..........................................................................  win32com.client import coclassbaseclass  ..........................................................................  class stiquote(coclassbaseclass): # coclass     # stiquote class     clsid = iid('{8eb74552-c174-4d51-819b-9e65a8916273}')     coclass_sources = [         _istiquoteevents,     ]     default_source = _istiquoteevents     coclass_interfaces = [         istiquote,     ]     default_interface = istiquote  ..........................................................................  istiquote_vtables_dispatch_ = 1 istiquote_vtables_ = [     (( u'registerquote' , u'bstrsymbol' , u'bstrexch' , ), 1, (1, (), [ (8, 1, none, none) ,              (8, 1, none, none) , ], 1 , 1 , 4 , 0 , 28 , (3, 0, none, none) , 0 , )),     (( u'deregisterquote' , u'bstrsymbol' , u'bstrexch' , ), 2, (2, (), [ (8, 1, none, none) ,              (8, 1, none, none) , ], 1 , 1 , 4 , 0 , 32 , (3, 0, none, none) , 0 , )),     (( u'deregisterallquotes' , ), 3, (3, (), [ ], 1 , 1 , 4 , 0 , 36 , (3, 0, none, none) , 0 , )),     (( u'registerformdx' , u'bmdx' , ), 4, (4, (), [ (11, 1, none, none) , ], 1 , 1 , 4 , 0 , 40 , (3, 0, none, none) , 0 , )),     (( u'registerforallmdx' , u'bmdx' , ), 5, (5, (), [ (11, 1, none, none) , ], 1 , 1 , 4 , 0 , 44 , (3, 0, none, none) , 0 , )),     (( u'getqueuecount' , u'lcount' , ), 6, (6, (), [ (16387, 10, none, none) , ], 1 , 1 , 4 , 0 , 48 , (3, 0, none, none) , 0 , )),     (( u'submitquote' , u'bstrkey' , u'retval' , ), 7, (7, (), [ (8, 1, none, none) ,              (16387, 10, none, none) , ], 1 , 1 , 4 , 0 , 52 , (3, 0, none, none) , 0 , )),     (( u'symbol' , u'pval' , ), 8, (8, (), [ (16392, 10, none, none) , ], 1 , 2 , 4 , 0 , 56 , (3, 0, none, none) , 0 , )),     (( u'symbol' , u'pval' , ), 8, (8, (), [ (8, 1, none, none) , ], 1 , 4 , 4 , 0 , 60 , (3, 0, none, none) , 0 , )),     (( u'exch' , u'pval' , ), 9, (9, (), [ (16392, 10, none, none) , ], 1 , 2 , 4 , 0 , 64 , (3, 0, none, none) , 0 , )),     (( u'exch' , u'pval' , ), 9, (9, (), [ (8, 1, none, none) , ], 1 , 4 , 4 , 0 , 68 , (3, 0, none, none) , 0 , )),     (( u'bidprice' , u'pval' , ), 10, (10, (), [ (16389, 10, none, none) , ], 1 , 2 , 4 , 0 , 72 , (3, 0, none, none) , 0 , )),     (( u'bidprice' , u'pval' , ), 10, (10, (), [ (5, 1, none, none) , ], 1 , 4 , 4 , 0 , 76 , (3, 0, none, none) , 0 , )),     (( u'askprice' , u'pval' , ), 11, (11, (), [ (16389, 10, none, none) , ], 1 , 2 , 4 , 0 , 80 , (3, 0, none, none) , 0 , )),     (( u'askprice' , u'pval' , ), 11, (11, (), [ (5, 1, none, none) , ], 1 , 4 , 4 , 0 , 84 , (3, 0, none, none) , 0 , )),     (( u'bidsize' , u'pval' , ), 12, (12, (), [ (16387, 10, none, none) , ], 1 , 2 , 4 , 0 , 88 , (3, 0, none, none) , 0 , )),     (( u'bidsize' , u'pval' , ), 12, (12, (), [ (3, 1, none, none) , ], 1 , 4 , 4 , 0 , 92 , (3, 0, none, none) , 0 , )),     (( u'asksize' , u'pval' , ), 13, (13, (), [ (16387, 10, none, none) , ], 1 , 2 , 4 , 0 , 96 , (3, 0, none, none) , 0 , )),     (( u'asksize' , u'pval' , ), 13, (13, (), [ (3, 1, none, none) , ], 1 , 4 , 4 , 0 , 100 , (3, 0, none, none) , 0 , )),     (( u'lastprice' , u'pval' , ), 14, (14, (), [ (16389, 10, none, none) , ], 1 , 2 , 4 , 0 , 104 , (3, 0, none, none) , 0 , )),     (( u'lastprice' , u'pval' , ), 14, (14, (), [ (5, 1, none, none) , ], 1 , 4 , 4 , 0 , 108 , (3, 0, none, none) , 0 , )),     (( u'destroy' , ), 15, (15, (), [ ], 1 , 1 , 4 , 0 , 112 , (3, 0, none, none) , 0 , )),     (( u'defaultqty' , u'pval' , ), 16, (16, (), [ (16387, 10, none, none) , ], 1 , 2 , 4 , 0 , 116 , (3, 0, none, none) , 0 , )),     (( u'defaultqty' , u'pval' , ), 16, (16, (), [ (3, 1, none, none) , ], 1 , 4 , 4 , 0 , 120 , (3, 0, none, none) , 0 , )),     (( u'defaultacct' , u'pval' , ), 17, (17, (), [ (16392, 10, none, none) , ], 1 , 2 , 4 , 0 , 124 , (3, 0, none, none) , 0 , )),     (( u'defaultacct' , u'pval' , ), 17, (17, (), [ (8, 1, none, none) , ], 1 , 4 , 4 , 0 , 128 , (3, 0, none, none) , 0 , )),     (( u'settradesonly' , u'btrades' , ), 18, (18, (), [ (11, 1, none, none) , ], 1 , 1 , 4 , 0 , 132 , (3, 0, none, none) , 0 , )),     (( u'defaultdest' , u'pval' , ), 19, (19, (), [ (16392, 10, none, none) , ], 1 , 2 , 4 , 0 , 136 , (3, 0, none, none) , 0 , )),     (( u'defaultdest' , u'pval' , ), 19, (19, (), [ (8, 1, none, none) , ], 1 , 4 , 4 , 0 , 140 , (3, 0, none, none) , 0 , )),     (( u'lastsize' , u'pval' , ), 20, (20, (), [ (16387, 10, none, none) , ], 1 , 2 , 4 , 0 , 144 , (3, 0, none, none) , 0 , )),     (( u'lastsize' , u'pval' , ), 20, (20, (), [ (3, 1, none, none) , ], 1 , 4 , 4 , 0 , 148 , (3, 0, none, none) , 0 , )),     (( u'level' , u'pval' , ), 21, (21, (), [ (16387, 10, none, none) , ], 1 , 2 , 4 , 0 , 152 , (3, 0, none, none) , 0 , )),     (( u'level' , u'pval' , ), 21, (21, (), [ (3, 1, none, none) , ], 1 , 4 , 4 , 0 , 156 , (3, 0, none, none) , 0 , )),     (( u'submitquotestruct' , u'bstrkey' , u'pquote' , u'retval' , ), 22, (22, (), [              (8, 1, none, none) , (36, 1, none, none) , (16387, 10, none, none) , ], 1 , 1 , 4 , 0 , 160 , (3, 0, none, none) , 0 , )),     (( u'registerforallnews' , u'bnews' , ), 23, (23, (), [ (11, 1, none, none) , ], 1 , 1 , 4 , 0 , 164 , (3, 0, none, none) , 0 , )),     (( u'registerfornewmdx' , u'bmdx' , u'ballsyms' , ), 24, (24, (), [ (11, 1, none, none) ,              (11, 1, none, none) , ], 1 , 1 , 4 , 0 , 168 , (3, 0, none, none) , 0 , )),     (( u'registerquoteex' , u'pquote' , ), 25, (25, (), [ (36, 1, none, none) , ], 1 , 1 , 4 , 0 , 172 , (3, 0, none, none) , 0 , )),     (( u'updateid' , u'pval' , ), 26, (26, (), [ (16387, 10, none, none) , ], 1 , 2 , 4 , 0 , 176 , (3, 0, none, none) , 0 , )),     (( u'updateid' , u'pval' , ), 26, (26, (), [ (3, 1, none, none) , ], 1 , 4 , 4 , 0 , 180 , (3, 0, none, none) , 0 , )),     (( u'registermdxex' , u'pmdx' , ), 27, (27, (), [ (36, 1, none, none) , ], 1 , 1 , 4 , 0 , 184 , (3, 0, none, none) , 0 , )),     (( u'registerl2' , u'pl2' , ), 28, (28, (), [ (36, 1, none, none) , ], 1 , 1 , 4 , 0 , 188 , (3, 0, none, none) , 0 , )), ]  ..........................................................................  recordmap = {     u'structstiquoteupdate': '{5d4a5541-619f-48ab-8e64-0cab14a92f6f}',     u'structstiquotesnap': '{5d4a5543-619f-48ab-8e64-0cab14a92f6f}',     u'structstitradeupdate': '{5d4a5544-619f-48ab-8e64-0cab14a92f6f}',     u'structstiorderupdate': '{5d4a5545-619f-48ab-8e64-0cab14a92f6f}',     u'structstiorderreject': '{5d4a5546-619f-48ab-8e64-0cab14a92f6f}',     u'structstiorderconfirm': '{5d4a5547-619f-48ab-8e64-0cab14a92f6f}',     u'structstipositionupdate': '{5d4a5548-619f-48ab-8e64-0cab14a92f6f}',     u'structstibookupdate': '{5d4a5549-619f-48ab-8e64-0cab14a92f6f}',     u'structstilink': '{5d4a5550-619f-48ab-8e64-0cab14a92f6f}',     u'structstiquoterqst': '{5d4a5551-619f-48ab-8e64-0cab14a92f6f}',     u'structstigreeksupdate': '{5d4a5552-619f-48ab-8e64-0cab14a92f6f}',     u'structstinewsupdate': '{5d4a5553-619f-48ab-8e64-0cab14a92f6f}',     u'structstiacctupdate': '{5d4a5554-619f-48ab-8e64-0cab14a92f6f}',     u'structstiorderfilter': '{5d4a5555-619f-48ab-8e64-0cab14a92f6f}',     u'structstitradefilter': '{5d4a5556-619f-48ab-8e64-0cab14a92f6f}',     u'structstidrop': '{5d4a5557-619f-48ab-8e64-0cab14a92f6f}',     u'structstiorder': '{5d4a5558-619f-48ab-8e64-0cab14a92f6f}',     u'structstiquoteregex': '{5d4a5559-619f-48ab-8e64-0cab14a92f6f}',     u'structstimdxregex': '{5d4a5560-619f-48ab-8e64-0cab14a92f6f}',     u'structsticancelall': '{5d4a5561-619f-48ab-8e64-0cab14a92f6f}',     u'structstil2reg': '{5d4a5562-619f-48ab-8e64-0cab14a92f6f}',     u'structstil2update': '{5d4a5563-619f-48ab-8e64-0cab14a92f6f}', }  clsidtoclassmap = { ..........................................................................     '{7482011f-7414-460b-92a8-693f1fdb8c27}' : _istiquoteevents,     '{8eb74552-c174-4d51-819b-9e65a8916273}' : stiquote, .......................................................................... } clsidtopackagemap = {} win32com.client.clsidtoclass.registerclsidsfromdict( clsidtoclassmap ) vtablestopackagemap = {} vtablestoclassmap = {     '{f8d282cc-fee7-45ec-a080-4276e43e8214}' : 'istiquote', }   namestoiidmap = {     'istiquote' : '{f8d282cc-fee7-45ec-a080-4276e43e8214}',     '_istiquoteevents' : '{7482011f-7414-460b-92a8-693f1fdb8c27}', }  win32com.client.constants.__dicts__.append(constants.__dict__) 


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -