WNDPROC in a class... no idea
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
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.
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).
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.
This was found as the first link on google with: site:www.gamedev.net window wrapper.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement