Original Post
Is there any rule against having a function pointer specify the callback procedure of a window? I want to handle user input differently in different situations, so I have two different WndProc functions: WndProcA, and WndProcB. I have a function pointer MyProc that is fed into the WNDCLASSEX structure. I can't seem to get it to compile though...
LRESULT CALLBACK (*MyProc)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
MyProc=&WndProcB
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = MyProc;
wc.cbClsExtra = 0;
//etc...
But I get these errors when I try to compile it.
error C2059: syntax error : '('
error C2065: 'MyProc' : undeclared identifier
error C2440: '=' : cannot convert from 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
error C2440: '=' : cannot convert from 'int' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
What can I do to fix this?
[edited by - Ranthalion on July 17, 2003 11:59:33 PM]