
各位大侠帮我我看下下面C++代码哪里是错误的,谢谢!
#include<windows.h>#include<WINBASE.H>voidmain(){typedefstruct_WNDCLASS{UINTstyle;WND...
#include <windows.h>
#include <WINBASE.H>
void main()
{
typedef struct _WNDCLASS {
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HINSTANCE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
} WNDCLASS, *PWNDCLASS;
HMODULE MKM;
WNDCLASS windows;
MKM=GetModuleHandle(0);
windows.style=0;
windows.lpfnWndProc=WndProc;
//定义函数指针
long CALLBACK WndProc(
WNDPROC lpPrevWndFunc, // pointer to previous procedure
HWND hWnd, // handle to window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
调试返回的结果为:
Compiling...
main1.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\main1\main1.cpp(21) : error C2065: 'WndProc' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\main1\main1.cpp(21) : 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
D:\Program Files\Microsoft Visual Studio\MyProjects\main1\main1.cpp(31) : error C2373: 'WndProc' : redefinition; different type modifiers
D:\Program Files\Microsoft Visual Studio\MyProjects\main1\main1.cpp(31) : error C2601: 'WndProc' : local function definitions are illegal
Error executing cl.exe.
main1.exe - 4 error(s), 0 warning(s)
)
{
return DefWindowProc(hwnd,message,wParam,lParam);
}
} 展开
#include <WINBASE.H>
void main()
{
typedef struct _WNDCLASS {
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HINSTANCE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
} WNDCLASS, *PWNDCLASS;
HMODULE MKM;
WNDCLASS windows;
MKM=GetModuleHandle(0);
windows.style=0;
windows.lpfnWndProc=WndProc;
//定义函数指针
long CALLBACK WndProc(
WNDPROC lpPrevWndFunc, // pointer to previous procedure
HWND hWnd, // handle to window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
调试返回的结果为:
Compiling...
main1.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\main1\main1.cpp(21) : error C2065: 'WndProc' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\main1\main1.cpp(21) : 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
D:\Program Files\Microsoft Visual Studio\MyProjects\main1\main1.cpp(31) : error C2373: 'WndProc' : redefinition; different type modifiers
D:\Program Files\Microsoft Visual Studio\MyProjects\main1\main1.cpp(31) : error C2601: 'WndProc' : local function definitions are illegal
Error executing cl.exe.
main1.exe - 4 error(s), 0 warning(s)
)
{
return DefWindowProc(hwnd,message,wParam,lParam);
}
} 展开
2个回答
展开全部
修改后:
#include <windows.h>
#include <WINBASE.H>
long CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);
void main()
{
HMODULE MKM;
WNDCLASS windows;
MKM=GetModuleHandle(0);
windows.style=0;
windows.lpfnWndProc=WndProc;
}
//定义函数指针
long CALLBACK WndProc(
HWND hWnd, // handle to window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
return DefWindowProc(hWnd,Msg,wParam,lParam);
}
#include <windows.h>
#include <WINBASE.H>
long CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);
void main()
{
HMODULE MKM;
WNDCLASS windows;
MKM=GetModuleHandle(0);
windows.style=0;
windows.lpfnWndProc=WndProc;
}
//定义函数指针
long CALLBACK WndProc(
HWND hWnd, // handle to window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
return DefWindowProc(hWnd,Msg,wParam,lParam);
}
2013-02-25
展开全部
你写的?你的复制时是不是复制错了,怎么看起来莫名其妙的?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询