WNDPROC in a class... no idea

Started by
15 comments, last by Verg 19 years, 9 months ago
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
Advertisement
Oh forget to tell that I'm working on the Micrsoft Visual Studio C++ 6.0
I've seen this question so many times it's crazy. If only people googled it before posting.
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.
You cannot.

(I did once see an asm solution, but never in practice)
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).
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...
"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).
as already mentioned, there is an article on the site: Creating a Win32 Window Wrapper Class

This was found as the first link on google with: site:www.gamedev.net window wrapper.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

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.

This topic is closed to new replies.

Advertisement