How to superclass a custom control and make it store additional data you need. The data should be stored for each instance of the control. I can allocate a data structure on WM_CREATE message and store a pointer to it with the corresponding window handle in an array. But it's hard to define by the window handle which pointer I have to use. I have to scan the entire array and compare the handle I get in my windowproc with the handles stored in it. When the handles match I get the right pointer to additional data structure. I don't like this way. Does anyone know the better one?
Posted on 2002-09-30 02:19:28 by Vaxon
You can call SetWindowLong with GWL_USERDATA flag and store your pointer to control instance itself.
And every time you need it again call GetWindowLong. When you don't need this instance of control anymore, you can fetch pointer from it, release memory and destroy control.
Posted on 2002-09-30 08:19:35 by Four-F
Thank you. I found yet another way: SetProp function:alright:
Posted on 2002-09-30 08:30:41 by Vaxon
With custom controls, you use the extra window memory that is available with the WNDCLASSEX structure for the CreateWindowEx() function call. On win95, this is limited to 40 bytes but this is large enough to hold addressing of allocated memory if you need larger. You set this up with SetWindowLong() and access the memory with GetWindowLong().

Posted on 2002-09-30 10:50:15 by hutch--
Thanks, Four-F and Hutch!
I think I'll use the SetWindowLong.
Posted on 2002-10-01 02:09:11 by Vaxon