Thanks Niall for your response and correction on HWND. I'm new to Python (and Boost.Python for that matter) and thought Python was not typed. If not, how can one convert Python integers to void*? Googled but didn't find an answer. Regards, Ehsan On Tue, May 1, 2012 at 9:18 AM, Niall Douglas <s_sourceforge@nedprod.com>wrote:
A HWND is always a void * i.e. an opaque pointer. Unfortunately some people using BPL think that BPL can't handle opaque pointers, so they do fun stuff like use a thunk struct type for void * instead, and wrap the lot in manual pointer casting. It's far easier just to declare it an opaque pointer and be done with it.
It is very unfortunate indeed that win32gui returns a HWND as an integer. It isn't an integer and must not be treated as one. Still, it's easy to write a routine which converts python integers to void *.
Niall
On 30 Apr 2012 at 14:54, Ehsan Pi wrote:
Thanks Roman for your quick reply,
That's what confuses me. HWND is essentially a pointer to an int to hold the window handle. How can to convert them to each other?
Ehsan
On Mon, Apr 30, 2012 at 2:46 PM, Roman Yakovenko <roman.yakovenko@gmail.com>wrote:
On Mon, Apr 30, 2012 at 9:11 PM, Ehsan Pi <ehsanpii@gmail.com> wrote:
In python I get the not-match error:
>>> import MyWrapper >>> import win32gui >>> hwnd = win32gui.GetDesktopWindow() >>> foo = MyWrapper.Foo(hwnd) Traceback (most recent call last): File "<stdin>", line 1, in <module> Boost.Python.ArgumentError: Python argument types in Foo.__init__(Foo, int) did not match C++ signature: __init__(struct _object *, struct HWND__ * window) >>>
How can I correct this problem to be able to pass a window's handle (from win32gui) in Python to C++ class, and interact with it?
I think the error is pretty clear: the exported constructor expects a pointer to some struct(?) HWND__, while, win32gui returns the handle as integer. You will have to find some way to associate handle as integer with handle as HWND__. Once you find it, you can use "make_constructor" functionality, which is also supported by py++.
HTH. _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
-- Technology & Consulting Services - ned Productions Limited. http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig