Windows and Subclassing - 'OverflowError': int too long to convert
I am subclassing a scintilla window and it happens every now and then
that I get an OverflowError. I've logged the message and could narrow down
is a single windows message which causes this trouble. It's WM_ERASEBKGND.
Now the confusing part for me is the following.
According to MS WPARAM
an UINT_PTR which is defined as
#if defined(_WIN64) typedef unsigned __int64 UINT_PTR; #else typedef
unsigned int UINT_PTR; #endif
wintypes.WPARAM is ctypes.c_ulonglong and is of size 8 on my system.
I'm on a x64 Windows - so far as good, right?
Now when I get this error the message I receive in this situation is always
hWnd=197364, msg=20, wParam=*18446744072652653190*, lParam=0
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 237, in 'calling callback function'
File "<string>", line 121, in new_scintilla2_proc
ctypes.ArgumentError: argument 4: <class 'OverflowError'>: int too long to
I really doubt that 18446744072652653190 is a valid device context but who
The question is, why do I even get this OverflowError?
If I do wintypes.WPARAM(18446744072652653190) I don't receive an exception
and it is a valid 64bit value, isn't it?
The code I'm using is this
user32 = ctypes.WinDLL('user32', use_last_error=True)
LRESULT = wintypes.LPARAM
WND_PROC = ctypes.WINFUNCTYPE(LRESULT,
user32.CallWindowProcW.restype = LRESULT
user32.CallWindowProcW.argtypes = [WND_PROC,
Any idea what might have caused this?
Thank you for reading