The first problem is on the first and the last line. You cannot create instance of class ChildControls called ChildControls. What you are doing is equivalent to ChildControls ChildControls; Also, you fail create instance of the class because contructor requires a paramater ( ChildControls(const HWND parent) )
Second, the callback function cannot be part of the class.
you told me for pass the 'this' for EnumWindows() function. and then i can use that way for catch the pointer.
i did the same thing for windows procedure, but don't works :(
when i create the control(CreateWindowEx()) i send the 'this' on last parameter and in window procedure i do: form *inst = (form*)lParam;
but by some reason i only get NULL... why?
The pointer is passed to your window procedure only once to WM_CREATE message. You must handle the WM_CREATE message, and save the pointer.
1 2 3 4 5 6 7 8 9
// in window procedure
form *inst=(form*)cs->lpCreateParams; // this value is equal to the last parameter of CreateWindoiwEx
SetWindowLongPtr(hwnd,GWL_USERDATA,(LONG_PTR)inst); // save it for later use
To get the pointer again, use GetwindowLongPtr:
// somewhere in window porocedure, when you need it