| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 749 人关注过本帖
标题:初学者请教程序中的错误问题(内附源程序)
只看楼主 加入收藏
Iamagays
Rank: 1
等 级:新手上路
帖 子:60
专家分:0
注 册:2007-6-21
收藏
 问题点数:0 回复次数:1 
初学者请教程序中的错误问题(内附源程序)

我初学VC++中利用API 编程的部分,按照书上说的原文写好一个源文件,但是在编译的时候还是出了很多问题,希望大家能够给分析一下,以下列出源文件和编译报错。熟悉API编程的仁兄帮我看看好么,谢谢了...

源文件
#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK WinSunProc(
HWND hwnd,
UNIT uMsg,
WPARAM wParam,
LPARAM lParam
);


int WINAPI WinMain(
HINSTANCE hInstance,//handle to current instance
HINSTANCE hPrevInstance,//handle to previous instance
LPSTR lpCmdLine,//commond line
int nShowCmd//show state
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="Weixin2003";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;

RegisterClass(&wndcls);

HWND hwnd;
hwnd=CreateWindow("Weixin2003","北京维新科学技术培训中心",WS_OVERLAPPEDWINDOW,
0,0,600,400,NULL,NULL,hINstance,NULL);

ShowWindow(hwnd,SW_SHOWNORMAL);

UpdateWindow(hwnd);

MSG msg;
while(GetMessage(&msg,NULL,0,0));
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}

LRESULT CALLBACK WinSunProc(
HWND hwnd,
UNIT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"weixin",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse clicked","weixin",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"计算机编程语言培训",strlen("计算机编程语言培训"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"维新培训",strlen("维新培训"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的结束?","weixin",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}


编译报错(以下画线部分我自己能够看懂错在哪里)
--------------------Configuration: WinMain3 - Win32 Debug--------------------
Compiling...
WinMain3.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(6) : error C2061: syntax error : identifier 'UNIT'
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(26) : error C2440: '=' : cannot convert from 'long (__stdcall *)(struct HWND__ *)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(35) : warning C4003: not enough actual parameters for macro 'CreateWindowA'
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(35) : error C2018: unknown character '0xa3'
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(35) : error C2018: unknown character '0xac'
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(35) : error C2064: term does not evaluate to a function
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(35) : error C2065: 'hINstance' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(35) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(52) : error C2061: syntax error : identifier 'UNIT'
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(57) : error C2065: 'uMsg' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(61) : error C2065: 'wParam' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\WinMain3\WinMain3.cpp(88) : error C2065: 'lParam' : undeclared identifier
执行 cl.exe 时出错.

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

搜索更多相关主题的帖子: 内附 windows API 
2007-09-03 00:16
dart
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-9-2
收藏
得分:0 
UINT 不是UNTI
2007-09-04 11:49
快速回复:初学者请教程序中的错误问题(内附源程序)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013482 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved