当前位置:编程学习 > VC++ >>

一个vc++程序 帮忙调试下 谢谢

//全局变量
HINSTANCE hInst;
HPEN hPen[7];
HBRUSH hBru[7];
int sPen[7] = {PS_SOLID,PS_DASH,PS_DOT,PS_DASHDOT,PS_DASHDOTDOT,PS_NULL,PS_INSIDEFRAME};
int sBru[6] = {HS_VERTICAL,HS_HORIZONTAL,HS_CROSS,HS_DIAGCROSS,HS_FDIAGONAL,HS_BDIAGONAL};
//***********初始化函数**************
//建立7种不同的画刷对象
BOOL InitInstance (HINSTANCE hInstance,int nCmdShow)
HWND hWnd;
int i;
hInst = hInstance;

hWnd = CreateWindow("canvas","绘图窗口",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);

if (!hWnd)
{
return FALSE;
}

MoveWindow(hWND,10,10,650,350,ture);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);

for(i=0;i<<6;i++)
{
hPen[i]=CreatePen(sPen[i],1,RGB(255,0,0));
if(i==6)
hBru[i]=CreateSolidBrush(RGB(0,255,0));
else
hBru[i]=CreateHatchBrush(sBru[i],RGB(0,255,0));
}
hdc=GetDC(hWnd);
MyPaint(hdc);
ReleaseDC(hWnd);

return TRUE;
}
//**************自定义绘图函数**************
//以各式画笔及画刷绘制线条和填充矩形
void MyPaint(HDC hdc)
{
int i,x1,x2,y;
//以7种不同的画笔绘制线条
for (i=0,i<6,i++)
{
y=(i+1)*30;

SelectObject(hdc,hPen[i]); //选用画笔
MoveToEx(hdc,30,y,NULL); //移到线条起点
LineTo(hdc,100,y);
}

x1=120;
x2=180;

//以7种不同的画刷填充矩形
for(i=0;i<=6;i++)
{
x1+=70;
x2+=70;

}

}
//*********消息处理函数**************
//1.窗口重绘时调用Mypaint()
//2.窗口结束消息发生时删除gdi对象
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT PS;
HDC hdc;
int i;
switch (message)
{
case WM_PAINT; //窗口重绘消息
hdc = BeginPaint(hWnd,&ps);
break;
case WM_DESTROY; //窗口结束消息
for(i=0;i<=6;i++)
{
DeleteObject(hPen[i]);
DeleteObject(hBru[i]);
}
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,message,wParam,lParam);


}
return 0;
}

调试后,出现以下错误

--------------------Configuration: Cpp123 - Win32 Debug--------------------
Compiling...
Cpp123.cpp
D:\Microsoft Visual Studio\源文件\Cpp123.cpp(2) : error C2018: unknown character '0xa3'
D:\Microsoft Visual Studio\源文件\Cpp123.cpp(2) : error C2018: unknown character '0xbb'
D:\Microsoft Visual Studio\源文件\Cpp123.cpp(3) : error C2146: syntax error : missing ';' before identifier 'hInst'
D:\Microsoft Visual Studio\源文件\Cpp123.cpp(3) : error C2501: 'HINSTANCE' : missing storage-class or type specifiers
D:\Microsoft Visual Studio\源文件\Cpp123.cpp(3) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

Cpp123.exe - 1 error(s), 0 warning(s)

追问:

恩 现在的错误有:

--------------------Configuration: Cpp123 - Win32 Debug--------------------
Compiling...
Cpp123.cpp
D:\Microsoft Visual Studio\源文件\Cpp123.cpp(2) : error C2146: syntax error : missing ';' before identifier 'hInst'
D:\Microsoft Visual Studio\源文件\Cpp123.cpp(2) : error C2501: 'HINSTANCE' : missing storage-class or type specifiers
D:\Microsoft Visual Studio\源文件\Cpp123.cpp(2) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

Cpp123.exe - 1 error(s), 0 warning(s)

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,