一个C++程序,#include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT,WPARAM,LPARAM);
#include<windows.h>LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);intAPIENTRYWinMain...
#include <windows.h>LRESULT CALLBACK WndProc(HWND, UINT,WPARAM,LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow){ WNDCLASS wndclass; HWND hwnd; MSG msg; wndclass.style=CS_HREDRAW|CS_VREDRAW; wndclass.lpfnWndProc =WndProc; wndclass.cbClsExtra =0; wndclass.cbWndExtra=0; wndclass.hInstance =hInstance; wndclass.hIcon =LoadIcon(NULL,IDI_APPLICATION); wndclass.hCursor =LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName =NULL; wndclass.lpszClassName ="window 窗口创建"; if(!RegisterClass(&wndclass)) return FALSE; hwnd=CreateWindow("window窗口创建","window窗口创建", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg,NULL,0,0)){ TranslateMessage(&msg); DispatchMessage(&msg); }
return msg.wParam ;
} LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam , LPARAM 45 lparam){ switch (message){ case WM_PAINT: HDC hdc; PAINTSTRUCT ps; hdc=BeginPaint(hwnd,&ps); TextOut(hdc,10,20,"哈哈,Windows 编程创建的窗口!",28); EndPaint(hwnd,&ps); return 0; case WM_DESTROY(0); PostQuitMessage(0); return 0; }
return DefWindowProc(hwnd,message,wParam,lParm);}
编译结果:
E:\学习资料\C\C++\程序练习\windowDemo\apidemo.cpp(36) : error C2143: syntax error : missing ')' before 'constant'E:\学习资料\C\C++\程序练习\windowDemo\apidemo.cpp(36) : error C2143: syntax error : missing ';' before 'constant'E:\学习资料\C\C++\程序练习\windowDemo\apidemo.cpp(36) : fatal error C1004: unexpected end of file found执行 cl.exe 时出错.
apidemo.obj - 1 error(s), 0 warning(s)
请问错在哪里了?
没看出来哪里丢“)”和“;”啊,还有第三个错误也没找出来,请大侠指点! 展开
return msg.wParam ;
} LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam , LPARAM 45 lparam){ switch (message){ case WM_PAINT: HDC hdc; PAINTSTRUCT ps; hdc=BeginPaint(hwnd,&ps); TextOut(hdc,10,20,"哈哈,Windows 编程创建的窗口!",28); EndPaint(hwnd,&ps); return 0; case WM_DESTROY(0); PostQuitMessage(0); return 0; }
return DefWindowProc(hwnd,message,wParam,lParm);}
编译结果:
E:\学习资料\C\C++\程序练习\windowDemo\apidemo.cpp(36) : error C2143: syntax error : missing ')' before 'constant'E:\学习资料\C\C++\程序练习\windowDemo\apidemo.cpp(36) : error C2143: syntax error : missing ';' before 'constant'E:\学习资料\C\C++\程序练习\windowDemo\apidemo.cpp(36) : fatal error C1004: unexpected end of file found执行 cl.exe 时出错.
apidemo.obj - 1 error(s), 0 warning(s)
请问错在哪里了?
没看出来哪里丢“)”和“;”啊,还有第三个错误也没找出来,请大侠指点! 展开
1个回答
展开全部
1. LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam , LPARAM 45 lparam)
这里不应该有45, 去掉.
2.
case WM_DESTROY(0);
去掉(0), ";"号换成":"
3.
return DefWindowProc(hwnd,message,wParam,lParm);
lParm 拼写错误,传进的参数是lparam, 同时注意大小写
这里不应该有45, 去掉.
2.
case WM_DESTROY(0);
去掉(0), ";"号换成":"
3.
return DefWindowProc(hwnd,message,wParam,lParm);
lParm 拼写错误,传进的参数是lparam, 同时注意大小写
追问
按照你说的改了,但是提示错误仍没有改变,还是三个相同的错误
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询