Reputation: 23498
In WINAPI, which is correct/necessary?
SetWindowLongPtr(HelpBox, GWLP_USERDATA, static_cast<LONG_PTR>(SetWindowLongPtr(HelpBox, GWLP_WNDPROC, (LONG_PTR)(Subclass))));
OR
SetWindowLongPtr(HelpBox, GWLP_WNDPROC, (LONG_PTR)(Subclass));
Then in WM_DESTROY I do both like:
SetWindowLong(HelpBox, GWLP_WNDPROC, (LONG) Original);
Why should I use the first one over the second? I noticed it had the GWLP_USERDATA and setwindowlongptr twice.. Why? I saw both examples on MSDN and I don't know when to use the first over the second.
Any ideas?
Upvotes: 1
Views: 701
Reputation: 145204
use SetWindowSubclass
instead; it handles the burden of associating data with the window. anyway. the first one stores the old window proc address in user data storage associated with the window, and you can't do that unless the window class is one you've defined yourself. i.e. where such storage does exist for the window where you are guaranteed that that storage isn't used for anything else.
Upvotes: 3