#include<windows.h>
LRESULT CALLBACK WndProc (HWMD,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,hPrevInstance,
PSTR szCmdLine,int iCmdShow)//error C2146: syntax error : missing ')' before identifier 'szCm
//error C2081: 'hPrevInstance' : name in formal parameter list il
//error C2081: 'PSTR' : name in formal parameter list illegal
//error C2061: syntax error : identifier 'szCmdLine'
//error C2059: syntax error : ';'
//error C2059: syntax error : ','/
//error C2059: syntax error : ')'
{
static TCHAR szAppName[]=TEXT("hELLOwIN");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
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.hbrBackgrond=(HBRUSH)GETsTOCKoBJECT(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if(!RegisterClass(&wndclass))
{
Message(NULL,TEXT("This program reqires Windows NT!"),
szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName,
TExt("The Hello Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,iCmdShow);
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 lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch (message)
{
case WM_CREATE:
PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
return 0;
case MWM_PAINT:
//error C2051: case expression not constant
// error C2065: 'MWM_PAINT' : undeclared identifier[b]
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwdn,&rect);
// error C2065: 'hwdn' : undeclared identifier
//warning C4047: 'function' : 'struct HWND__ *' differs in levels of indirection from 'int '
//warning C4024: 'GetClientRect' : different types for formal and actual parameter 1
DrawText(hdc,TEXT("Hello,Windows 98!"),-1,&rect,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case MWM_DESTROY:
//error C2051: case expression not constant
//error C2065: 'MWM_DESTROY' : undeclared identifier
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
uj5u.com熱心網友回復:
#include <afx.h>uj5u.com熱心網友回復:
#include <afx.h> ,測驗一下。uj5u.com熱心網友回復:
#include <afx.h> ,測驗一下。 秘密uj5u.com熱心網友回復:
各位,不管用啊。貼上去后還是一堆錯誤……uj5u.com熱心網友回復:
是HWND,而不是HWMDHINSTANCE,hPrevInstance 這里中間多了個逗號
uj5u.com熱心網友回復:
是wndclass.hbrBackground而不是 wndclass.hbrBackgrond是GetStockObject而不是GETsTOCKoBJECT
是TEXT而不是TExt
小問題太多,只找到這
uj5u.com熱心網友回復:
對于有問題的陳述句加了/**/注釋然后另起一行寫了修正后的陳述句#include<windows.h>
/*LRESULT CALLBACK WndProc (HWMD,UINT,WPARAM,LPARAM);*/
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);
/*int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,hPrevInstance,*/
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
PSTR szCmdLine,int iCmdShow)//error C2146: syntax error : missing ')' before identifier 'szCm
//error C2081: 'hPrevInstance' : name in formal parameter list il
//error C2081: 'PSTR' : name in formal parameter list illegal
//error C2061: syntax error : identifier 'szCmdLine'
//error C2059: syntax error : ';'
//error C2059: syntax error : ','/
//error C2059: syntax error : ')'
{
static TCHAR szAppName[]=TEXT("hELLOwIN");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
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.hbrBackgrond=(HBRUSH)GETsTOCKoBJECT(WHITE_BRUSH);*/
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if(!RegisterClass(&wndclass))
{
/*Message(NULL,TEXT("This program reqires Windows NT!"),*/
MessageBox(NULL,TEXT("This program reqires Windows NT!"),
szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName,
/*TExt("The Hello Program"),*/
TEXT("The Hello Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,iCmdShow);
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 lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch (message)
{
case WM_CREATE:
PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
return 0;
/*case MWM_PAINT:*/
case WM_PAINT:
//error C2051: case expression not constant
// error C2065: 'MWM_PAINT' : undeclared identifier[b]
hdc=BeginPaint(hwnd,&ps);
/*GetClientRect(hwdn,&rect);*/
GetClientRect(hwnd,&rect);
// error C2065: 'hwdn' : undeclared identifier
//warning C4047: 'function' : 'struct HWND__ *' differs in levels of indirection from 'int '
//warning C4024: 'GetClientRect' : different types for formal and actual parameter 1
DrawText(hdc,TEXT("Hello,Windows 98!"),-1,&rect,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
/*case MWM_DESTROY:*/
case WM_DESTROY:
//error C2051: case expression not constant
//error C2065: 'MWM_DESTROY' : undeclared identifier
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/132604.html
上一篇:事情是這樣的
