[Python.NET] Trying to constructu a System.IntPtr object

Mark McMahon mark.mcmahon at eur.autodesk.com
Fri Jul 29 18:45:30 CEST 2005


Hi,

I am stumped by this one - googled, even read the Readme!!

I want to call System.Forms.Control.FromHandle() to get a control from a
handle. But I am getting that handle as Python int instance but
FromHandle requires a System.IntPtr.

I would have guess that there would be automatic conversion from Python
int to .Net IntPtr.

>>> CLR.System.IntPtr(23)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'int' value cannot be converted to System.IntPtr

So I try converting it to Int32 first... (same for Int64)

>>> CLR.System.IntPtr(CLR.System.Int32(23))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: value cannot be converted to System.IntPtr

So now I am stuck - any help appreciated,

Thanks
	Mark


More information about the PythonDotNet mailing list