Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2341818
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:04:55

# include
# include

LRESULT CALLBACK WinSunProc(HWND hwhd,MSG uMsg,WPARAM wParam,LPARAM lParam);


int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrelnstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASS wncls;
wncls.cbClsExtra=0;
wncls.cbWndExtra=0;
wncls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wncls.hCursor=LoadCursor(NULL,IDC_ARROW);
wncls.hIcon=LoadIcon(NULL,IDI_ERROR);
wncls.hInstance=hInstance;
wncls.lpfnWndProc=WinSunProc;
wncls.lpszClassName="lee2004";
wncls.lpszMenuName=NULL;
wncls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wncls);

HWND hwnd;
hwnd=CreateWindow("LEE2004","冰红茶工作室",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 hwhd,MSG uMsg,WPARAM wParam,LPARAM IParam)
{
switch(uMsg)
{
case WM_CHAR:
char szchar[20];
sprintf(szchar,"你输入的字符的ASCII码为:d%",wParam);
MessageBox(hwnd,szchar,"冰红茶工作室",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"哈喽!鼠标左键!","lee2004",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,500,384,"冰红茶工作室永远辉煌!",strlen("冰红茶工作室永远辉煌!"));
ReleaseDC(hwnd);
break;
case WM_PAINT:
HDC hDc;
PAINTSTRUCT ps;
hDc=BeginPaint(hwnd,ps);
TextOut(hDc,500,200,"黑客从此诞生",strlen("黑客从此诞生"));
EndPaint(hwnd,ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的要退出?","冰红茶工作室",IDYESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTORY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
}


--------------------next---------------------

阅读(939) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~