-
Subclassing in a class
I have a label class that needs to subclass its parent window whenever it's initialized. Now when I declared the window procedure inside the class and then try to set the window procedure to new one, I have to call like "&myclass::WindowProc" but that gives me an error message because I have to pass the arguements of WindowProc with it too. If I declared WindowsProc outside of the class then it'll work using "&WindowProc" but I won't be able to access any of the myclass members from inside the procedure and I won't recieve any message after that in my real window procedure because then I'll have two window procedures handling the messages for same window at the same time. I want to make the first method (declaring the window procedure as a function if the class and then somehow correctly passing its address as the new window procedure - not call the actual window procedure includign its arguements) work but maybe you have any idea of how to get it working that way.
-
It has nothing to do with parameters. It's just that normal class members are of calltype __thiscall and can therefore not be used as __stdcall (= CALLBACK) functions. You can use a static class member, which still can't access member variables but at least has access rights (so if you pass a pointer to the class object to the function and it stores it somewhere you can access private members).
-
I guess that will be a bit messy so I thought of another method. I ask the user (who is using the class) to just pass whatever it gets in the messages "WM_DRAWITEM" and "WM_MEASUREITEM" to one of the class functions and then it performs all the measuring and drawing. It'll then also be able to access the class' member functions. Sounds good idea?
-
Not if you actually want to distribute that class.