代码如下:#include<windows.h>
#include "stdafx.h"
long FAR PASCAL WindowFun( HWND, UINT, WPARAM, LPARAM);int WinAPI WinMain(HANDLE CurInstance,
HANDLE PreInstance,
LPSTR CmdParaStr,
int ShowStyle)
{
static char ProgName[]="Myprog1_1";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
if(!PreInstance)
{
wndclass.lpszClassName=ProgName;
wndclass.hInstance=CurInstance;
wndclass.lpfnWndProc=WindowFun;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_IBEAM);
wndclass.lpszMenuName=NULL;
wndclass.hbrBackground=GetStockObject(WHITE_BRUSH);
wndclass.style=CS_HREDRAW | CS_VREDRAW;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
RegisterClass(&wndclass);
}
hwnd=GreateWindow(ProgName,
ProgName,
WS_OVERLAPPEDWINDOW,
100,
100,
300,
200,
NULL,
NULL,
CurInstance,
NULL);
Show Window(hwnd,ShowStyle);
while(GetMeasage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}long FAR PASCAL WindowFun(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
}
错误:
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(7) : error C2146: syntax error : missing ';' before identifier 'WinMain'
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(7) : fatal error C1004: unexpected end of file found是什么错误?
该怎么解决?
#include "stdafx.h"
long FAR PASCAL WindowFun( HWND, UINT, WPARAM, LPARAM);int WinAPI WinMain(HANDLE CurInstance,
HANDLE PreInstance,
LPSTR CmdParaStr,
int ShowStyle)
{
static char ProgName[]="Myprog1_1";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
if(!PreInstance)
{
wndclass.lpszClassName=ProgName;
wndclass.hInstance=CurInstance;
wndclass.lpfnWndProc=WindowFun;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_IBEAM);
wndclass.lpszMenuName=NULL;
wndclass.hbrBackground=GetStockObject(WHITE_BRUSH);
wndclass.style=CS_HREDRAW | CS_VREDRAW;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
RegisterClass(&wndclass);
}
hwnd=GreateWindow(ProgName,
ProgName,
WS_OVERLAPPEDWINDOW,
100,
100,
300,
200,
NULL,
NULL,
CurInstance,
NULL);
Show Window(hwnd,ShowStyle);
while(GetMeasage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}long FAR PASCAL WindowFun(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
}
错误:
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(7) : error C2146: syntax error : missing ';' before identifier 'WinMain'
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(7) : fatal error C1004: unexpected end of file found是什么错误?
该怎么解决?
解决方案 »
- 求 Windows下,解压缩 *.Z 的方案
- MFC界面中使用picture控件的问题?
- 请问标准输入、输出从定向后,可以读写二进制文件吗?
- 怎么让toolbar用上PNG图片,就像马桶(Maxthon2.0)的工具栏
- 关与far???的问题
- vc中用ado连接的access,如何获取数据库的字段名称啊?
- 新手请教:根据数据,使用opengl画三维实体
- 多线程中如何刷新listctrl内容
- 如何在FlexGrid中设置多行选中标记?
- 对话框的标题去掉,就不可已拖动对话框了,除了这种方法还有其他方法吗?
- 【50分】恳求高手指点--Xtreme Toolkit Pro
- 在我的程序里如何编一个运行其他程序的程序
WinAPI 改为 WINAPI 试试
Compiler Error C2146
syntax error : missing 'token' before identifier 'identifier'The compiler expected the given token to appear before the given identifier.TipsThis error is usually preceeded by error C2065. The most typical cause of this error is a typographical problem. For example:void main(void)
{
intt x; //Syntax error: missing semicolon before 'x'
}
MyPog1.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(11) : error C2731: 'WinMain' : function cannot be overloaded
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(7) : see declaration of 'WinMain'
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(19) : error C2440: '=' : cannot convert from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(24) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(30) : error C2065: 'GreateWindow' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(40) : 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
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(41) : error C2065: 'Show' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(41) : error C2146: syntax error : missing ';' before identifier 'Window'
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(41) : error C2065: 'Window' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\MyPog1\MyPog1.cpp(42) : error C2065: 'GetMeasage' : undeclared identifier
Error executing cl.exe.MyPog1.exe - 9 error(s), 0 warning(s)
更多错!
{
static char ProgName[]="Myprog1_1";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
int ShowStyle = SW_SHOW;
if(!PreInstance)
{
wndclass.lpszClassName=ProgName;
wndclass.hInstance=CurInstance;
wndclass.lpfnWndProc=WindowFun;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_IBEAM);
wndclass.lpszMenuName=NULL;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.style=CS_HREDRAW | CS_VREDRAW;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
RegisterClass(&wndclass);
}
hwnd=CreateWindow(ProgName,
ProgName,
WS_OVERLAPPEDWINDOW,
100,
100,
300,
200,
NULL,
NULL,
CurInstance,
NULL);
ShowWindow(hwnd,ShowStyle);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}long FAR PASCAL WindowFun(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
}修改后的代码
看仔细些
这么耐心的帮助我,VC我是初学者,以后还要多帮忙!