Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 ActiveX Exe in Python
Index -> Programming, Python -> Python Tutorials
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
drtwkim




PostPosted: Wed Apr 15, 2009 4:30 am   Post subject: ActiveX Exe in Python

Python에서 VB로 만든 ActiveX Exe를 사용하고자 합니다
그러나 이벤트를 받아오지 못하네요
- VB ActiveX DLL : DLL로 만들경우 폼의 vbmodeless로 만들수 없구
- VB ActvieX EXE : EXE로 만들경우 Event가 반환이 되지 않네요

code:

Python Source Start -------------------------

import win32com.client

#event handler
class VBEventHandler:
    def __init__(self):
        pass
   
    def OnClickToolbar(self,id):
        try:
            print id
        except:
            print "error"

def run():
    obj = win32com.client.DispatchWithEvents("DHToolBarVB.VBToolBar",VBEventHandler)

    try:
        obj.ShowWindow()
       
        obj = None
    except:
        print "main error"
        obj = None
   
if __name__ == '__main__':
    run()

End source ---------------------------------------------

VB Source Start -----------------------------------------
[Fom source]

' Event in Form module
Public Event OnClickToolbar(ByVal ID As Integer)

' RaiseEvent
Private Sub cmdToolbar_Click(Index As Integer)
    RaiseEvent OnClickToolbar(Index)
    If Index = cmdToolbar.UBound Then
            Unload Me
    End If
End Sub

[Class Source]

Private WithEvents fm As fmToolbar
Public Event OnClickToolbar(ByVal ID As Integer)

'-------------------------------------
'  Class event
'-------------------------------------
Private Sub fm_OnClickToolbar(ByVal ID As Integer)
    RaiseEvent OnClickToolbar(ID)
End Sub


'--------------------------------------
'   Class Initialize & Terminate
'--------------------------------------
Private Sub Class_Initialize()

    Set fm = New fmToolbar
End Sub


Private Sub Class_Terminate()
    If Not fm Is Nothing Then Set fm = Nothing
End Sub


'--------------------------------------
'   class method
'--------------------------------------
Public Sub ShowWindow()
    fm.Show vbModeless
End Sub

Public Sub DestroyWindow()
    Set fm = Nothing
End Sub



## Help me!!
Sponsor
Sponsor
Sponsor
sponsor
Zeroth




PostPosted: Wed Apr 15, 2009 3:44 pm   Post subject: Re: ActiveX Exe in Python

Umm... I don't think any of us can read chinese or korean, or whatever that is. What is your problem, please, in english?
Display posts from previous:   
   Index -> Programming, Python -> Python Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: