我制作了一个简单的 windows api 程序,具有 WinMain() 和 WinProc() 函数,但我收到了这个错误:
error C2440: '=' : cannot convert from 'LRESULT (__stdcall *)(HWND,UINT,LPARAM,WPARAM)' to 'WNDPROC'
1> This conversion requires a reinterpret_cast, a C-style cast or function-style cast
#include<windows.h>
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, LPARAM lParam, WPARAM wParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WindowClass;
static LPCTSTR szAppName = L"OFWin";
HWND hWnd;
MSG msg;
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style = CS_HREDRAW | CS_VREDRAW;
WindowClass.lpfnWndProc = WindowProc; // error
....
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, LPARAM lParam, WPARAM wParam)
{ ..... }
该程序从我的书中逐字逐句(ivor horton's beginning visual c++ 2010),有什么问题?