关于“error C2440: '=' : cannot convert from 'int' to 'struct HWND_ *'有关问题”
关于“error C2440: '=' : cannot convert from 'int' to 'struct HWND__ *'问题”
源程序:
--------------------------------------------------------------
#include<windows.h>
WNDCLASS wc;
HWND h_wnd;
MSG msg;
long WINAPI WindowProc(HWND,UINT,WPARAM,LPARAM);
int PASCAL WinMain(HINSTANCE h_CurInstance,HINSTANCE h_PrevInstance,LPSTR p_CmdLine,int m_Show)
{ /*初始化wndclass结构变量*/
wc.lpfnWndProc =WindowProc;
wc.hInstance =h_CurInstance;
wc.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszClassName ="TheMainClass";
/*注册WndClass结构变量*/
RegisterClass(&wc);
/*创建窗口*/
h_wnd = GreateWindow("TheMainClass","Our first Window",WS_OVERLAPPEDWINDOW,0,0,400,500,0,0,h_CurInstance,0);
/*显示窗口*/
ShowWindow(h_wnd, SW_SHOWMAXIMIZED);
/*消息循环*/
while(GetMessage(&msg,NULL,0,0))
DispatchMessage(&msg);
return (msg.wParam );
}
/*定义消息处理函数*/
long WINAPI WindowProc(HWND h_wnd,UINT WinMsg,WPARAM w_param,LPARAM l_param)
{
if(WinMsg==WM_DESTROY)
PostQuitMessage(0);
return DefWindowProc(h_wnd,WinMsg,w_param,l_param);
}
-----------------------------------------------------------------
错误信息提示:
-----------------------------------------------------------------
Compiling...
proj3_8.cpp
F:\My Code\C++\proj3_8\proj3_8.cpp(15) : error C2065: 'GreateWindow' : undeclared identifier
F:\My Code\C++\proj3_8\proj3_8.cpp(15) : error C2440: '=' : cannot convert from 'int' to 'struct HWND__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
-----------------------------------------------------------------
不知这个出错的原因是什么?
------解决方案--------------------
GreateWindow 应该是 CreateWindow,改过来再试试。
源程序:
--------------------------------------------------------------
#include<windows.h>
WNDCLASS wc;
HWND h_wnd;
MSG msg;
long WINAPI WindowProc(HWND,UINT,WPARAM,LPARAM);
int PASCAL WinMain(HINSTANCE h_CurInstance,HINSTANCE h_PrevInstance,LPSTR p_CmdLine,int m_Show)
{ /*初始化wndclass结构变量*/
wc.lpfnWndProc =WindowProc;
wc.hInstance =h_CurInstance;
wc.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszClassName ="TheMainClass";
/*注册WndClass结构变量*/
RegisterClass(&wc);
/*创建窗口*/
h_wnd = GreateWindow("TheMainClass","Our first Window",WS_OVERLAPPEDWINDOW,0,0,400,500,0,0,h_CurInstance,0);
/*显示窗口*/
ShowWindow(h_wnd, SW_SHOWMAXIMIZED);
/*消息循环*/
while(GetMessage(&msg,NULL,0,0))
DispatchMessage(&msg);
return (msg.wParam );
}
/*定义消息处理函数*/
long WINAPI WindowProc(HWND h_wnd,UINT WinMsg,WPARAM w_param,LPARAM l_param)
{
if(WinMsg==WM_DESTROY)
PostQuitMessage(0);
return DefWindowProc(h_wnd,WinMsg,w_param,l_param);
}
-----------------------------------------------------------------
错误信息提示:
-----------------------------------------------------------------
Compiling...
proj3_8.cpp
F:\My Code\C++\proj3_8\proj3_8.cpp(15) : error C2065: 'GreateWindow' : undeclared identifier
F:\My Code\C++\proj3_8\proj3_8.cpp(15) : error C2440: '=' : cannot convert from 'int' to 'struct HWND__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
-----------------------------------------------------------------
不知这个出错的原因是什么?
------解决方案--------------------
GreateWindow 应该是 CreateWindow,改过来再试试。