CompuServe Messages

GWL_USERDATA Bug?

    09-Aug-93 11:49:44
Sb: GWL_USERDATA Bug?
Fm: Patrick Parks 70324,407
To: sysop (X)
Does Get/SetWindowLong officially support GWL_USERDATA under Win32s? If so there's a bug in SetWindowLong. It always returns 1 regardless of value that was previously stored in this slot. It's clear that GWL_USERDATA uses some kind of special handling since it's value is -21 (not exactly a multiple of 4). Once I've set the value GetWindowLong seems to always get the correct value back. It's just that SetWindowLong doesnt' return displaced value correctly. It's easy to work around this using GetWindowLong first but just wanted you to be aware of the problem. This bug was discovered just after installing the Final NT release and Win32s version 1.1. I've curious how GWL_USERDATA is actually implemented under Win32s? I suspect it might be done via Get/SetProp since there surely won't be a slot in the Win 3.1 USER data structures for this data. That might explain why a BOOL seems to be getting returned by SetWindowLong (passing thru the result of SetProp). The App where this problem occur started life as a Win16 app. I ported it to Win32 and have been working under NT. I was using SetProp to attach window data to some subclassed controls. But when I tried running this under Win32s the SetProp failed. I guess that's because I was passing a Win32 local handle (32-bit) but call was getting thunked to Win16 SetProp which wouldn't accept this (will only take a 16-bit handle). So I rooted around and discovered GWL_USERDATA and it seems to work (except for SetWindowLong result bug). Question: is GWL_USERDATA supported under Win32s? Question: if it uses SetProp to implement under Win32s I'd prefer to avoid the extra overhead and just call SetProp directly as I was doing. So please let me know if SetProp is really at the heart of GWL_USERDATA implementation under Win32s. How about under WinNT? Is GWL_USERDATA more directly supported? Thanks, Patrick