阿拉胡阿嘛 阿拉胡阿嘛
红日+红林道のid选号群
关注数: 0 粉丝数: 56 发帖数: 950 关注贴吧数: 4
写个小程序送给大家,祝大家元旦快乐 #include #include LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow){MSG msg;static TCHAR szAppName[]=TEXT("HappyNewYear");HWND hwnd;WNDCLASS wndclass;wndclass.cbClsExtra=NULL;wndclass.cbWndExtra=NULL;wndclass.hbrBackground=CreateSolidBrush(RGB(255,255,255));wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);wndclass.hIcon=LoadCursor(NULL,IDI_APPLICATION);wndclass.hInstance=hInstance;wndclass.lpfnWndProc=WndProc;wndclass.lpszClassName=szAppName;wndclass.lpszMenuName=NULL;wndclass.style=CS_HREDRAW|CS_VREDRAW;if(!RegisterClass(&wndclass)){MessageBox(NULL,TEXT("the program requires windows NT"),szAppName,MB_OK|MB_ICONERROR);return 0;}hwnd=CreateWindow(szAppName,TEXT("元旦快乐!"),WS_OVERLAPPED|WS_CAPTION,0,0,100,50,NULL,NULL,hInstance,NULL);ShowWindow(hwnd,SW_SHOWNORMAL);UpdateWindow(hwnd);while(GetMessage(&msg,NULL,0,0)){TranslateMessage(&msg);DispatchMessage(&msg);}return msg.wParam;}TCHAR* szFont(int i){switch(i){case 0:return TEXT("黑体");case 1:return TEXT("仿宋_GB2312");case 2:return TEXT("楷体_GB2312");}}void Thread(PVOID pvoid){HDC hdc;int iRed,iGreen,iBlue;HFONT hFont;int x,y;static int cxWindow=GetSystemMetrics(SM_CXSCREEN),cyWindow=GetSystemMetrics(SM_CYSCREEN);static TCHAR szBuffer[]=TEXT("元旦快乐!");while(true){iRed=rand()%255;iBlue=rand()%255;iGreen=rand()%255;y=rand()%50+20;x=y*3/6;hdc=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);SetTextColor(hdc,RGB(iRed,iGreen,iBlue));hFont=CreateFontA(y,x,0,0,700,0,0,0,DEFAULT_CHARSET,0,0,0,0,szFont(rand()%3)); SelectObject(hdc,hFont);TextOut(hdc,rand()%cxWindow,rand()%cyWindow,szBuffer,lstrlen(szBuffer));DeleteObject(hFont);DeleteDC(hdc);Sleep(500);}}LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){HDC hdc;static TCHAR szBuffer[]=TEXT("按空格键结束程序");PAINTSTRUCT ps;switch(message){case WM_CREATE:_beginthread(Thread,0,NULL);return 0;case WM_CHAR:if(wParam==VK_SPACE)SendMessage(hwnd,WM_DESTROY,0,0);return 0;case WM_PAINT:hdc=BeginPaint(hwnd,&ps);TextOut(hdc,10,0,szBuffer,lstrlen(szBuffer));EndPaint(hwnd,&ps);return 0;case WM_DESTROY:InvalidateRect(0,NULL,true);PostQuitMessage(0);return 0;}return DefWindowProc(hwnd,message,wParam,lParam);}
1 下一页