Question : Callback function in class

Hello, experts!
I need some help with callback function in class, i can't to assign it from external source. I know it's easy, but i can't understand it, please help.
source above:
header file:
 
1:
2:
3:
4:
5:
6:
7:
8:
class SomeClass
{
private:
//...
public:
	typedef void (CALLBACK *SOMEFUNC)();
        SOMEFUNC* SomeFunc();
};

source file:
 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
void OnSomeFunc()
{
	MessageBox(0,0,0,0);
	
}

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	SomeClass * myClass = new SomeClass();
	MainForm->SomeFunc = OnSomeClass; //it's says "error C2659: '=' : function as left operand"
        //...
}


please halp to set callback to this function :(

Answer : Callback function in class

Same with the CALLBACK. A bit different from what evilrix says but the same meaning.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
#include <Windows.h>

class SomeClass  
{  
public:  
	typedef void (CALLBACK *SOMEFUNC)();  
	SOMEFUNC SomeFunc;  
};

void __stdcall OnSomeFunc()  
{  
	MessageBox(NULL, L"Hello", L"A test", MB_OK | MB_SETFOREGROUND);  

}  

int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
					  LPWSTR lpCmdLine, int nCmdShow)
{
	SomeClass * myClass = new SomeClass();  
	myClass->SomeFunc = OnSomeFunc;  
	myClass->SomeFunc();

	delete myClass;
	return 0;
}
Random Solutions  
 
programming4us programming4us