c++6.0的程序运行总是不通过,求大神分析一下?

Superxia999 2017-12-12 08:03:46
#include<windows.h>
INT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
char szClassName[]="windowclass1";
char szAppTitle[]="chen";
INT PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdParam,INT nCmdShow)
{
HWND hMainWnd;
MSG msg;
WNDCLASS myWC;
if(!hPrevInstance)
{
myWC.style=CS_HREDRAW|CS_VREDRAW;
myWC.lpfnWndProc=WndProc;
myWC.cbClsExtra=0;
myWC.cbWndExtra=0;
myWC.hInstance=hInstance;
myWC.hIcon=LoadIcon(NULL,IDI_APPLICATION);
myWC.hCursor=LoadCursor(NULL,IDC_ARROW);
myWC.hbrBackground=GetStockObject(WHITE_BRUSH);
myWC.lpszMenuName=NULL;
myWC.lpszClassName=szClassName;
}
hMainWnd=CreateWindow(
szClassName,
szAppTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
ShowWindow(hMainWnd,SW_SHOWMAXIMIZED);
UpdateWindow(hMainWnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
INT CALLBACK WndProc(HWND hMainwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
char messageleft[]="the left button have been pushed";
char messageright[]="the right button have been pushed";
switch(message)
{
case WM_RBUTTONDOWN:
{
MessageBox(GetFocus(),messageright,"chen",MB_OK|MB_ICONINFORMATION);
break;
}

case WM_LBUTTONDOWN:
{
MessageBox(GetFocus(),messageleft,"chen",MB_OK|MB_ICONINFORMATION);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
default:
break;
}
return DefWindowProc(hMainwnd,message,wParam,lParam);
}


Configuration: progect4 - Win32 Debug--------------------
Compiling...
4.1.cpp
F:\software C++ 6.0\C++ Book 6.0\progect4\4.1.cpp(13) : error C2440: '=' : cannot convert from 'int (__stdcall *)(struct HWND__ *,unsigned int,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
F:\software C++ 6.0\C++ Book 6.0\progect4\4.1.cpp(19) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.

4.1.obj - 2 error(s), 0 warning(s)

...全文
223 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
晕 看的有点晕
夫人的泡泡鱼 2017-12-13
  • 打赏
  • 举报
回复
再学习下孙鑫的视频,模拟MFC窗口的启动过程。
zgl7903 2017-12-13
  • 打赏
  • 举报
回复
LRESULT CALLBACK WndProc(HWND hMainwnd,UINT message,WPARAM wParam,LPARAM lParam)
qq_36252226 2017-12-13
  • 打赏
  • 举报
回复
这个信息已经有了呀,提示的清清楚楚的,哪里不明白
schlafenhamster 2017-12-12
  • 打赏
  • 举报
回复
不是 INT CALLBACK WndProc long WINAPI WndProc #define CALLBACK __stdcall #define WINAPI __stdcall #define WINAPIV __cdecl #define APIENTRY WINAPI #define APIPRIVATE __stdcall #define PASCAL __stdcall yong WINAPI

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧