[python-win32] Negative HWND values from win32gui.EnumChildWindows

Tim Roberts timr at probo.com
Mon Aug 26 19:43:27 CEST 2013


Kelly Kranabetter wrote:
>
> I am occasionally getting back negative HWND values from
> EnumChildWindows. They appear to round trip properly, for example
> win32gui.GetClassName(-1901131990) appears to function properly. Not
> exactly a bug but is somewhat unexpected.
>
>  
>
> I had grabbed this code from the net somewhere to get the currently
> focused window which returns HWND as an unsigned long:
>
> ...
>
> My code would fail occasionally and I’d wonder why but never got into
> debugging it until one day it was failing constantly. After much head
> scratching the simple fix for me was to change the focus-finding-code
> to use ctypes.c_long so the result is not unsigned from both HWND sources.
>

How does this cause a failure?  c_long and c_ulong are both 32-bit
quantities.  It shouldn't cause a problem.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list