Results 1 to 4 of 4

Thread: Subclassing in a class

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    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.
    Baaaaaaaaah

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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?
    Baaaaaaaaah

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Not if you actually want to distribute that class.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width