[python-win32] RE: OCX dilemma (round 2)

Larry Bates lbates@syscononline.com
Mon, 5 Aug 2002 10:20:01 -0500


Mark,

If I EVER get this working I'm going to write a tutorial and
post it somewhere.  Thanks for the additional information.
I was apparently trying to make it harder than it is.  I
knew that there was some significance to the line I saw in
the generated makepy file that read:

# This CoClass is known by the name 'RTKOCR.RtkocrCtrl.1'

was meaningful but for the life of me I couldn't figure out
what to do with it.

Follow-up question:

The following program now aborts with an Unexpected failure error.

import win32com
from win32com import client
RtkocrCtrl=win32com.client.Dispatch("RTKOCR.RtkocrCtrl.1")
BaseDir="C:\\Program Files\\ExperVision\\OpenRTK 6.1"
TempDir="C:\\temp"
CustomerID="600-RTK-6395803603"
#
# Call Init method of the OCX
#
sErrorNo=RtkocrCtrl.Init(BaseDir,TempDir,CustomerID)

Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File
"c:\python21\win32com\gen_py\AA6B2720-ACDE-11CF-8BB0-0080C80C4FAEx0x1x0.py",
line 41, in DispError
    return self._oleobj_.InvokeTypes(0x8, LCID, 1, (24, 0), ((2, 0),),usErrorNo)
com_error: (-2147418113, 'Unexpected failure', None, None)

I've triple checked the Init variables, looked at the VB example (see below) and
I just don't see what I'm doing incorrectly.  Any thoughts?

VB Example:

Private Sub InitBtn_Click()
    Dim sErrorNo As Long

    Dim BaseDir As String
    BaseDir = BaseDirText.Text
    Dim TempDir As String
    TempDir = BaseDirText.Text
    ShowMessage ("Initializing...")
    sErrorNo = RtkocrCtrl.Init(BaseDir, TempDir, CustomerID)
    If sErrorNo <> 0 Then
        RtkocrCtrl.DispError (sErrorNo)
    Else
        ShowMessage ("Init Success!")
    End If
End Sub

Thanks,
Larry Bates

-----Original Message-----
From: python-win32-admin@python.org
[mailto:python-win32-admin@python.org]On Behalf Of
python-win32-request@python.org
Sent: Sunday, August 04, 2002 11:00 AM
To: python-win32@python.org
Subject: Python-win32 digest, Vol 1 #182 - 1 msg


Send Python-win32 mailing list submissions to
	python-win32@python.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://mail.python.org/mailman/listinfo/python-win32
or, via email, send a message with subject or body 'help' to
	python-win32-request@python.org

You can reach the person managing the list at
	python-win32-admin@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-win32 digest..."


Today's Topics:

   1. RE: OCX dilemma (Mark Hammond)

--__--__--

Message: 1
From: "Mark Hammond" <mhammond@skippinet.com.au>
To: <lbates@syscononline.com>,
	<python-win32@python.org>
Subject: RE: [python-win32] OCX dilemma
Date: Sun, 4 Aug 2002 02:24:37 +1000

> 1) The OCX is installed on my system and shows up in browser
> 2) I have run example program that came with toolkit that uses
>    the OCX and it works perfectly.
> 3) I ran makepy and it generated a module that while cryptic,
>    appears to work.  At least I can import it without errors.
> 4) I can create instantiate a class using the class that
>    was defined by makepy, but I can't seem to do anything
>    with it.
>
> Example:
>
> I had makepy put it's output for the OCX into rtkocr.py
>
> from rtkocr import *

This isnt the preferred way of doing this.  Generally you should just run
makepy, and just use win32com.client.Dispatch() with the progID of the
application.  You will find this in any VB/JS samples.

> r=Rtkocr()              # This instantiates a class
> print r

You probably want to instantiate an 'interface'.  The generated code may
well have some comments of the form "this obhect can be created by prog ID
xxx", and these are the objects you want to create, rather than the
"coclass" classes.

If you use the prog ID, it should just work.

> r.default_interface shows me the methods that I'm looking
> to be able to call.  The first one I need to call is Init
>
> result=r.default_interface.Init(pBasePath,pTempPath,pCustID)

Well, if you *really* want to continue down this route <wink>,
default_interface is exactly the class you need.
r.default_interface().Init(...) would work, but

In the makepy file the Rtkocr class, another class will be named as the
default_interface.  This is the class name you could instantite instead of
Rtkocr, and it should also work.

Mark.




--__--__--

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


End of Python-win32 Digest