943566987 发表于 2014-8-9 14:38:47

关于WndProc回调函数

我在编译一个WINDOWS窗口时提示
error C2440: '=' : cannot convert from 'long (__stdcall *)(struct HWND__ *,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'This conversion requires a reinterpret_cast, a C-style cast or function-style cast

LRESULT CALLBACK WndProc(HWND,UINT WPARAM,LPARAM);
#define ID_TIMER 1
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                  PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wnd;
static char szAppName[] = TEXT ("Beeper1") ;
wnd.style=CS_HREDRAW|CS_VREDRAW;
wnd.lpfnWndProc = WndProc;
wnd.cbWndExtra=0;
wnd.cbClsExtra=0;
wnd.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wnd.hCursor=LoadCursor(NULL,IDC_ARROW);
wnd.hIcon=LoadIcon(NULL,IDI_WINLOGO);
wnd.hInstance=hInstance;
wnd.lpszMenuName=0;
wnd.lpszClassName = szAppName;

我琢磨了老半天也不知道那错了 求大神指教

仰望天上的光 发表于 2014-8-9 14:38:48

把LRESULT CALLBACK WndProc(HWND,UINT WPARAM,LPARAM);改为:
   LRESULT CALLBACK WndProc(HWND,UINT, WPARAM,LPARAM);

即在UINT WPARAM之间加个逗号

943566987 发表于 2014-8-9 23:23:52

仰望天上的光 发表于 2014-8-9 17:24
把LRESULT CALLBACK WndProc(HWND,UINT WPARAM,LPARAM);改为:
   LRESULT CALLBACK WndProc(HWND,UINT, W ...

:sweat: 有粗心了。。。。

小甲鱼 发表于 2014-8-10 14:01:01

943566987 发表于 2014-8-9 23:23
有粗心了。。。。

问题解决就顺便把分类改为“已解决”状态,另外悬赏也请及时奖励给帮到你的朋友哦~~

careless 发表于 2014-8-10 18:12:13

支持學習學習

小毛奇 发表于 2014-8-11 14:04:15

这个很粗细呀你

智商是硬伤 发表于 2015-8-25 07:32:40

{:7_146:}
页: [1]
查看完整版本: 关于WndProc回调函数