新手Windows程序消息机制实现中出现的问题(VC++6.0中)

ylwdi 2010-01-10 02:02:21

#include"winuser.h"
#include"stdio.h"
#include"windows.h"

LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);

int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{

WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackgrourd=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.style=CS_VREDRAW|CS_HREDRAW;
wndclass.hIcon=LoadIcon(NULL,IDI_ERROR);
wndclass.hCursor=LoadCursor(NULL,IDC_CROSS);
wndclass.hInstance=Instance;
wndclass.wndProc=WinSonProc;
wndclass.lpszClassName="lesson1";
wndclass.lpszMenuName=NULL;
Register(&wndclass);
HWND hwnd;
hwnd=CreateWindow("lesson1","yanglinwei",WS_OVERLAPPEDWINDOW,0,0,500,600,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,hwnd,0,0))
{ TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"lesson1",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse click","lesson1",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,20,40,"i love you",strlen("i love you"));
Release(hwnd,hdc);
break;
case WM_PAINT:
HDC hdc;
PAINTSTUCT ps;
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,30,40,"i love you",strlen("i love you"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwdn,"是否真的关闭?","yanglinwei",MB_YESNO))
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}

f:\cyuyanyu\vc++英文版\[大家网]visual.c++.6.en[www.topsage.com]\vc98\include\winuser.h(39) : error C2146: syntax error : missing ';' before identifier 'HDWP'
f:\cyuyanyu\vc++英文版\[大家网]visual.c++.6.en[www.topsage.com]\vc98\include\winuser.h(39) : fatal error C1004: unexpected end of file found

下面是winuser.h中的一段代码
#include <stdarg.h>
#ifndef NOUSER

typedef HANDLE HDWP; (以上两个错误都指向这一行)
typedef VOID MENUTEMPLATEA;
typedef VOID MENUTEMPLATEW;
#ifdef UNICODE
typedef MENUTEMPLATEW MENUTEMPLATE;
#else
typedef MENUTEMPLATEA MENUTEMPLATE;
#endif // UNICODE
找不出原因,请大家帮帮忙
...全文
101 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wltg2001 2010-01-10
  • 打赏
  • 举报
回复
老实说,你上面代码的拼写错误实在太多了!
schlafenhamster 2010-01-10
  • 打赏
  • 举报
回复
#include <windows.h>
#include <winuser.h>//放这里
wltg2001 2010-01-10
  • 打赏
  • 举报
回复
一般来说系统文件不会错的,#include"winuser.h"这个可以删除掉
hfcarrey 2010-01-10
  • 打赏
  • 举报
回复
类库怎么会出错?
不知道是不是你的路径太深了?
f:\cyuyanyu\vc++英文版\[大家网]visual.c++.6.en[www.topsage.com]\vc98\include\winuser.h
是找另外的机器试试

15,978

社区成员

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

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