Original Post
Cheers, I have a question about something that's been tearing my mind for some time...
Is it possible to make the windows callback a class member...? Or to access class members via the callback if it's not a class member...? I've tried a few times, without any luck.
Some pseudo code from the top of my head ---
Main wrapper
Foobar class header
Foobar class
So if i instead try to get to the class member in the callback...
Well, I need to get this working in someway, and my only option at this time is to pick out the functions i access from the callback out of the classes and make them 'global' (can't find the word i'm looking for...).
Can't find any tutorials on it either...
Thanks in advance.
[edited by - prankster on January 3, 2003 7:30:13 AM]
[edited by - prankster on January 3, 2003 7:30:52 AM]
[edited by - prankster on January 3, 2003 7:31:59 AM]
//winmain.cpp
//
int WINAPI WinMain(etc...)
{
// Class registration and main window creation is done in the
// foobar class constructor
CFoobar* foo = new CFoobar();
...
...
}
//foobar.h
//
class CFoobar{
CFoobar();
virtual~ CFoobar();
// Possible??
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
};
//foobar.cpp
//
CFoobar::CFoobar()
{
WNDCLASS wc;
ZeroMemory(...);
...
...
wc.WndProc = WndProc; // Doesn't work, i've tried casting as well (bad idéa :))
}
LRESULT CALLBACK WndProc(...)
{
CFoobar *foo = (CFoobar*)GetWindowLong(hwnd, GWL_USERDATA);
...
...
case WM_BLAH:
{
foo->DoSomething(); // Access violation...
} break;
...
...
}