Jump to content
  • Advertisement
Sign in to follow this  
psae0001

WNDPROC in a class... no idea

This topic is 5095 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I've trying to figure out how to put the CALLBACK WndProc function inside class--without assign "static" infront it. However, I can never do it when I try to get the address for WNDCLASSEX / WNDCLASS. I guess probably many of you have tried, so I'm looking for the solution. --------------- Just a simple codes here ------------------ #include <windows.h> #include <stdio.h> #include <stdlib.h> class Test1 { public: void testing (); LRESULT CALLBACK wndproc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); } int main () { WNDPROC temp1 = Test1::wndproc; // <--- for sure error int i = Test1::wndproc; // NEVER works fprintf (stderr, "%d\n", Test1::wndproc); // Surpringly this line has no error and function correctly!!! ------------------------ end of simple ------------------------- Ok, if I put a static infront of the LRESULT, the code "WNDPROC temp1 = Test1::wndproc;" will work. But, the callback function can't call the "testing ()" since it's a non-static. The more crazy thing I don't understand is htf can the fprintf able to print the address of the wndproc as an integer, while the "int i = Test1::wndproc; " will get a compiler error as well.... So I got 2 main questions: 1) WNDPROC temp1 = (What should I put here?) Test1::wndproc; and is it possible to obtain the address of wndproc since it's inside a class and non-static function? 2) Or I should just make my own call back function and a dummy one for the WNDPROC temp1 to register? Thank you for the help

Share this post


Link to post
Share on other sites
Advertisement
I've searching online more than weeks probably a month. I can't find any solution to tell how to obtain the address of wndproc, and I want to the callback function inside the class (if possible) because it'll give lots of advantages.

Share this post


Link to post
Share on other sites
Of the two options you posted, the second would probably be easier. (Would take a bit of hacking to get the first one done..), but google has plenty of links, and a site called GDNet has a tutorial on this, written by Oluseyi (can't be bothered to find the clicky right now).

Share this post


Link to post
Share on other sites
Quote:

I've searching online more than weeks probably a month. I can't find any solution to tell how to obtain the address of wndproc, and I want to the callback function inside the class (if possible) because it'll give lots of advantages.

here: http://www.rpi.edu/~pudeyo/articles/wndproc/
It was the first link after googling it; I even posted a link to the search results...

Share this post


Link to post
Share on other sites
"here: http://www.rpi.edu/~pudeyo/articles/wndproc/
It was the first link after googling it; I even posted a link to the search results..."

I read that one a few times already (before posted this thread), I'm still searching a better solution (don't want to use MFC / ATL).

Share this post


Link to post
Share on other sites
Ok, http://www.gamedev.net/reference/articles/article1810.asp
pretty much it's telling the samething that

WNDPROC temp1 = Test1::wndproc; <--- this code is never possible.

And, I guess, the only solution is to create my own callback function and set a dummy one for the WINCLASSEX / WINCLASS.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!