[python-win32] exactly how to pass a vb6 form to python

Thomas Barket tbarket@OptOnline.net
Thu, 26 Dec 2002 01:34:19 -0800 (PST)


ive seen lots of examples, esp in the python win32
book) of how to access a python COM server by a VB6
COM client to create nice gui that uses python as its
core analytical engine.  however, i am interested in
the reverse: to control a VB6 gui from python.  i have
read people say they pass a VB6 form to python,
however i am not able to do this.  for instance, in a
VB6 project, i have a form called "SomeForm" and a
class called "SomeClass" (see below).  when i compile
this as an activex exe, i can successfully load the
activex control and i can successfully display the
form by running the "ShowForm" method of the
"SomeClass" class.

My problem is that i cant figure out how to pass the
form back to python so python can control it directly.
 i tried the "GiveAccess" method for "SomeClass" below
but i get a compilation error telling me that i cannot
use private object modules in public object modules as
a return type.  VB6's object browser definitely says
the SomeForm is a Private class, and i cannot figure
out how to make it public.  what am i doing wrong
here?  is there some simple, contrived example for how
to successfully pass a VB6 form into python, so python
can control its methods and attributes?

(Ive seen Andy Robinson's nice Doubletalk example but
that doesnt help me bc that is based on using python
as a COM server and VB6 as the COM client.  I see how
he manages to pass a form back to the python COM
server but that isnt what i want bc i dont want a
python COM server.)


Tom Barket

***** SomeClass has the following methods: *****
Public Function ShowForm()
    SomeForm.Visible = True
End Function

'The following wont compile:
'Public Function GiveAccess() As Form    
'    GiveAccess2 = SomeForm
'End Function

***** The module has the following: *****
Sub Main()
    Dim obj As New SomeClass
End Sub

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.