
-----------------------------------
drtwkim
Wed Apr 15, 2009 4:30 am

ActiveX Exe in Python
-----------------------------------
Python&#50640;&#49436; VB&#47196; &#47564;&#46304; ActiveX Exe&#47484; &#49324;&#50857;&#54616;&#44256;&#51088; &#54633;&#45768;&#45796;
&#44536;&#47084;&#45208; &#51060;&#48292;&#53944;&#47484; &#48155;&#50500;&#50724;&#51648; &#47803;&#54616;&#45348;&#50836;
- VB ActiveX DLL : DLL&#47196; &#47564;&#46308;&#44221;&#50864; &#54268;&#51032; vbmodeless&#47196; &#47564;&#46308;&#49688; &#50630;&#44396;
- VB ActvieX EXE : EXE&#47196; &#47564;&#46308;&#44221;&#50864; Event&#44032; &#48152;&#54872;&#51060; &#46104;&#51648; &#50506;&#45348;&#50836;

[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

[/code]

## Help me!!

-----------------------------------
Zeroth
Wed Apr 15, 2009 3:44 pm

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?
