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?
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.
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.
Thank you. I found yet another way: SetProp function:alright:
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().
Regards,
hutch@movsd.com
Regards,
hutch@movsd.com
Thanks, Four-F and Hutch!
I think I'll use the SetWindowLong.
I think I'll use the SetWindowLong.