I am writing a program using Win32API (not MFC). The following code had compiled in earlier versions of VC++, but in VC++5.0 it gives compile error, which I am not able to solve. The code is as follows (taken from Win32 Programming by Brent E. Rector and Joseph M. Newcomer, pg 782-783):


BOOL CALLBACK selectProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam);
LPPIZZA getPizzaSelection(HWND hwnd)
{
LPPIZZA pizza = (LPPIZZA)DialogBoxParam(GetWindowInstance(hwnd),
MAKEINTRESOURCE(DLG_SELECTPIZZA), hwnd, selectProc,
(LPARAM)PizzaTable);

return pizza;
}




The compile error on the first statement in the function is as follows:

D:\pradyumn\proj05\pizza.cpp(43) : error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'int (void *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(void)'

Basically, DIalogBoxParam function's fourth parameter is the name of the callback function for the dialog box. In this case, I am specifying selectProc whose forward declaration is also given above.

When I change the code of the getPizzaSelection function to the following:


DLGPROC x = selectProc;
LPPIZZA pizza = (LPPIZZA)DialogBoxParam(GetWindowInstance(hwnd),
MAKEINTRESOURCE(DLG_SELECTPIZZA), hwnd, x,
(LPARAM)PizzaTable);

return pizza;




Then the compile error is:

D:\pradyumn\proj05\pizza.cpp(41) : error C2440: 'initializing' : cannot convert from 'int (__stdcall *)(void *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(void)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast

What do I need to do to solve this problem?