WinAPI给女友画朵玫瑰

来源:互联网 发布:山东理工大学网络 编辑:程序博客网 时间:2024/04/27 13:33

女友生日那天,写了朵玫瑰,很笨的办法,画了好久。在同一目录下,放3个名为:HappyBirthday.wav,love.wav,tonghua.wav音乐文件,会有意想不到的哦!

#include <windows.h>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow){static TCHARszAppName[] = TEXT ("Happy Birthday!");HWNDhwnd;MSGmsg;WNDCLASSwcls;wcls.cbClsExtra= 0;wcls.cbWndExtra= 0;wcls.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH);wcls.hCursor= LoadCursor (NULL, IDC_ARROW);wcls.hIcon= LoadIcon (NULL, IDI_APPLICATION);wcls.hInstance= hInstance;wcls.lpfnWndProc= WndProc;wcls.lpszClassName= szAppName;wcls.lpszMenuName= NULL;wcls.style= CS_HREDRAW | CS_VREDRAW;if (!RegisterClass (&wcls)){MessageBox (NULL, TEXT ("Program requires WinNT!"), szAppName, MB_ICONERROR);}hwnd = CreateWindow (szAppName, TEXT("Happy Birthday"),WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,WS_MAXIMIZEBOX, WS_MINIMIZEBOX,NULL, NULL, hInstance, NULL);ShowWindow (hwnd, iCmdShow);UpdateWindow (hwnd);while (GetMessage (&msg, NULL, 0, 0)){TranslateMessage (&msg);DispatchMessage (&msg);}return msg.wParam;}LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){static POINTbpt[4];HDChdc;PAINTSTRUCTps;intcxClient, cyClient;switch (message){case WM_SIZE:cxClient = LOWORD (lParam);cyClient = HIWORD (lParam);return 0;case WM_CREATE:PlaySound (TEXT ("HappyBirthday.wav"), NULL, SND_FILENAME | SND_ASYNC);return 0;case WM_RBUTTONDOWN:PlaySound (TEXT ("tonghua.wav"), NULL, SND_FILENAME | SND_ASYNC);return 0;case WM_LBUTTONDOWN:PlaySound (TEXT ("love.wav"), NULL, SND_FILENAME | SND_ASYNC);return 0;case WM_PAINT:InvalidateRect (hwnd, NULL, TRUE);hdc = BeginPaint (hwnd, &ps);TextOut (hdc, 744, 380, TEXT("L"), 1);TextOut (hdc, 702, 400, TEXT("Love You Forever..."), 19);TextOut (hdc, 731, 413, TEXT("o"), 1);TextOut (hdc, 724, 432, TEXT("v"), 1);TextOut (hdc, 717, 451, TEXT("e"), 1);TextOut (hdc, 709, 472, TEXT("Y"), 1);TextOut (hdc, 703, 487, TEXT("o"), 1);TextOut (hdc, 693, 505, TEXT("u"), 1);TextOut (hdc, 736, 436, TEXT(" Forever.."), 10);TextOut (hdc, 755, 451, TEXT("L"), 1);TextOut (hdc, 755, 464, TEXT("o"), 1);TextOut (hdc, 755, 478, TEXT("v"), 1);TextOut (hdc, 755, 490, TEXT("e"), 1);TextOut (hdc, 717, 505, TEXT("LoveYouForever"), 14);SelectObject (hdc, CreatePen (PS_SOLID, 3, RGB(255,0,0)));bpt[0].x = 300;bpt[0].y = 70;bpt[1].x = 365;bpt[1].y = 119;bpt[2].x = 256;bpt[2].y = 198;bpt[3].x = 400;bpt[3].y = 200;PolyBezier (hdc, bpt, 4);bpt[0].x = 300;bpt[0].y = 70;bpt[1].x = 348;bpt[1].y = 67;bpt[2].x = 454;bpt[2].y = 154;bpt[3].x = 400;bpt[3].y = 200;PolyBezier (hdc, bpt, 4);bpt[0].x = 405;bpt[0].y = 195;bpt[1].x = 494;bpt[1].y = 195;bpt[2].x = 421;bpt[2].y = 100;bpt[3].x = 460;bpt[3].y = 60;PolyBezier (hdc, bpt, 4);bpt[0].x = 405;bpt[0].y = 195;bpt[1].x = 492;bpt[1].y = 164;bpt[2].x = 406;bpt[2].y = 124;bpt[3].x = 447;bpt[3].y = 66;PolyBezier (hdc, bpt, 4);bpt[0].x = 412;bpt[0].y = 75;bpt[1].x = 413;bpt[1].y = 63;bpt[2].x = 436;bpt[2].y = 59;bpt[3].x = 447;bpt[3].y = 66;PolyBezier (hdc, bpt, 4);bpt[0].x = 374;bpt[0].y = 104;bpt[1].x = 376;bpt[1].y = 85;bpt[2].x = 413;bpt[2].y = 75;bpt[3].x = 447;bpt[3].y = 66;PolyBezier (hdc, bpt, 4);bpt[0].x = 374;bpt[0].y = 104;bpt[1].x = 328;bpt[1].y = 46;bpt[2].x = 340;bpt[2].y = 27;bpt[3].x = 374;bpt[3].y = 53;PolyBezier (hdc, bpt, 4);bpt[0].x = 412;bpt[0].y = 75;bpt[1].x = 397;bpt[1].y = 75;bpt[2].x = 392;bpt[2].y = 76;bpt[3].x = 385;bpt[3].y = 67;PolyBezier (hdc, bpt, 4);bpt[0].x = 351;bpt[0].y = 70;bpt[1].x = 361;bpt[1].y = 62;bpt[2].x = 372;bpt[2].y = 78;bpt[3].x = 385;bpt[3].y = 67;PolyBezier (hdc, bpt, 4);bpt[0].x = 414;bpt[0].y = 70;bpt[1].x = 405;bpt[1].y = 55;bpt[2].x = 393;bpt[2].y = 61;bpt[3].x = 391;bpt[3].y = 47;PolyBezier (hdc, bpt, 4);bpt[0].x = 357;bpt[0].y = 68;bpt[1].x = 362;bpt[1].y = 46;bpt[2].x = 385;bpt[2].y = 56;bpt[3].x = 391;bpt[3].y = 47;PolyBezier (hdc, bpt, 4);bpt[0].x = 344;bpt[0].y = 50;bpt[1].x = 343;bpt[1].y = 64;bpt[2].x = 345;bpt[2].y = 69;bpt[3].x = 340;bpt[3].y = 80;PolyBezier (hdc, bpt, 4);bpt[0].x = 300;bpt[0].y = 70;bpt[1].x = 317;bpt[1].y = 60;bpt[2].x = 319;bpt[2].y = 56;bpt[3].x = 345;bpt[3].y = 61;PolyBezier (hdc, bpt, 4);bpt[0].x = 366;bpt[0].y = 46;bpt[1].x = 382;bpt[1].y = 30;bpt[2].x = 391;bpt[2].y = 49;bpt[3].x = 409;bpt[3].y = 37;PolyBezier (hdc, bpt, 4);bpt[0].x = 434;bpt[0].y = 62;bpt[1].x = 434;bpt[1].y = 53;bpt[2].x = 415;bpt[2].y = 55;bpt[3].x = 409;bpt[3].y = 37;PolyBezier (hdc, bpt, 4);bpt[0].x = 433;bpt[0].y = 58;bpt[1].x = 440;bpt[1].y = 53;bpt[2].x = 450;bpt[2].y = 53;bpt[3].x = 460;bpt[3].y = 60;PolyBezier (hdc, bpt, 4);SelectObject (hdc, CreatePen (PS_SOLID, 3, RGB(0,128,0)));bpt[0].x = 390;bpt[0].y = 200;bpt[1].x = 374;bpt[1].y = 211;bpt[2].x = 375;bpt[2].y = 227;bpt[3].x = 376;bpt[3].y = 236;PolyBezier (hdc, bpt, 4);bpt[0].x = 343;bpt[0].y = 233;bpt[1].x = 357;bpt[1].y = 238;bpt[2].x = 360;bpt[2].y = 238;bpt[3].x = 376;bpt[3].y = 236;PolyBezier (hdc, bpt, 4);bpt[0].x = 343;bpt[0].y = 233;bpt[1].x = 324;bpt[1].y = 227;bpt[2].x = 336;bpt[2].y = 201;bpt[3].x = 357;bpt[3].y = 196;PolyBezier (hdc, bpt, 4);bpt[0].x = 335;bpt[0].y = 215;bpt[1].x = 321;bpt[1].y = 210;bpt[2].x = 322;bpt[2].y = 210;bpt[3].x = 317;bpt[3].y = 204;PolyBezier (hdc, bpt, 4);bpt[0].x = 332;bpt[0].y = 185;bpt[1].x = 322;bpt[1].y = 184;bpt[2].x = 313;bpt[2].y = 196;bpt[3].x = 317;bpt[3].y = 204;PolyBezier (hdc, bpt, 4);bpt[0].x = 397;bpt[0].y = 200;bpt[1].x = 408;bpt[1].y = 245;bpt[2].x = 445;bpt[2].y = 235;bpt[3].x = 410;bpt[3].y = 260;PolyBezier (hdc, bpt, 4);bpt[0].x = 440;bpt[0].y = 185;bpt[1].x = 460;bpt[1].y = 222;bpt[2].x = 460;bpt[2].y = 241;bpt[3].x = 410;bpt[3].y = 260;PolyBezier (hdc, bpt, 4);bpt[0].x = 385;bpt[0].y = 205;bpt[1].x = 385;bpt[1].y = 261;bpt[2].x = 385;bpt[2].y = 240;bpt[3].x = 385;bpt[3].y = 280;PolyBezier (hdc, bpt, 4);bpt[0].x = 395;bpt[0].y = 200;bpt[1].x = 395;bpt[1].y = 238;bpt[2].x = 395;bpt[2].y = 265;bpt[3].x = 395;bpt[3].y = 280;PolyBezier (hdc, bpt, 4);SelectObject (hdc, CreatePen (PS_SOLID, 3, RGB(238,81,85)));bpt[0].x = 376;bpt[0].y = 279;bpt[1].x = 384;bpt[1].y = 278;bpt[2].x = 396;bpt[2].y = 280;bpt[3].x = 400;bpt[3].y = 281;PolyBezier (hdc, bpt, 4);bpt[0].x = 376;bpt[0].y = 279;bpt[1].x = 381;bpt[1].y = 284;bpt[2].x = 381;bpt[2].y = 285;bpt[3].x = 381;bpt[3].y = 302;PolyBezier (hdc, bpt, 4);bpt[0].x = 399;bpt[0].y = 299;bpt[1].x = 399;bpt[1].y = 299;bpt[2].x = 396;bpt[2].y = 299;bpt[3].x = 381;bpt[3].y = 302;PolyBezier (hdc, bpt, 4);bpt[0].x = 399;bpt[0].y = 299;bpt[1].x = 403;bpt[1].y = 284;bpt[2].x = 397;bpt[2].y = 283;bpt[3].x = 400;bpt[3].y = 281;PolyBezier (hdc, bpt, 4);bpt[0].x = 470;bpt[0].y = 290;bpt[1].x = 446;bpt[1].y = 272;bpt[2].x = 428;bpt[2].y = 274;bpt[3].x = 400;bpt[3].y = 281;PolyBezier (hdc, bpt, 4);bpt[0].x = 470;bpt[0].y = 290;bpt[1].x = 471;bpt[1].y = 297;bpt[2].x = 463;bpt[2].y = 313;bpt[3].x = 460;bpt[3].y = 320;PolyBezier (hdc, bpt, 4);bpt[0].x = 400;bpt[0].y = 296;bpt[1].x = 413;bpt[1].y = 290;bpt[2].x = 454;bpt[2].y = 303;bpt[3].x = 460;bpt[3].y = 320;PolyBezier (hdc, bpt, 4);bpt[0].x = 399;bpt[0].y = 299;bpt[1].x = 415;bpt[1].y = 310;bpt[2].x = 435;bpt[2].y = 323;bpt[3].x = 460;bpt[3].y = 320;PolyBezier (hdc, bpt, 4);bpt[0].x = 383;bpt[0].y = 302;bpt[1].x = 374;bpt[1].y = 308;bpt[2].x = 348;bpt[2].y = 326;bpt[3].x = 332;bpt[3].y = 324;PolyBezier (hdc, bpt, 4);bpt[0].x = 383;bpt[0].y = 302;bpt[1].x = 366;bpt[1].y = 296;bpt[2].x = 338;bpt[2].y = 295;bpt[3].x = 332;bpt[3].y = 324;PolyBezier (hdc, bpt, 4);bpt[0].x = 320;bpt[0].y = 280;bpt[1].x = 316;bpt[1].y = 288;bpt[2].x = 317;bpt[2].y = 315;bpt[3].x = 332;bpt[3].y = 324;PolyBezier (hdc, bpt, 4);bpt[0].x = 320;bpt[0].y = 280;bpt[1].x = 347;bpt[1].y = 271;bpt[2].x = 362;bpt[2].y = 278;bpt[3].x = 377;bpt[3].y = 280;PolyBezier (hdc, bpt, 4);SelectObject (hdc, CreatePen (PS_SOLID, 3, RGB(0,128,0)));bpt[0].x = 370;bpt[0].y = 500;bpt[1].x = 385;bpt[1].y = 422;bpt[2].x = 389;bpt[2].y = 354;bpt[3].x = 385;bpt[3].y = 300;PolyBezier (hdc, bpt, 4);bpt[0].x = 382;bpt[0].y = 500;bpt[1].x = 399;bpt[1].y = 378;bpt[2].x = 394;bpt[2].y = 330;bpt[3].x = 394;bpt[3].y = 300;PolyBezier (hdc, bpt, 4);bpt[0].x = 382;bpt[0].y = 500;bpt[1].x = 377;bpt[1].y = 501;bpt[2].x = 379;bpt[2].y = 504;bpt[3].x = 370;bpt[3].y = 500;PolyBezier (hdc, bpt, 4);SelectObject (hdc, CreatePen (PS_SOLID, 3, RGB(238,81,85)));bpt[0].x = 400;bpt[0].y = 300;bpt[1].x = 471;bpt[1].y = 385;bpt[2].x = 396;bpt[2].y = 421;bpt[3].x = 430;bpt[3].y = 480;PolyBezier (hdc, bpt, 4);bpt[0].x = 450;bpt[0].y = 450;bpt[1].x = 449;bpt[1].y = 448;bpt[2].x = 430;bpt[2].y = 463;bpt[3].x = 430;bpt[3].y = 480;PolyBezier (hdc, bpt, 4);bpt[0].x = 450;bpt[0].y = 450;bpt[1].x = 424;bpt[1].y = 440;bpt[2].x = 481;bpt[2].y = 380;bpt[3].x = 437;bpt[3].y = 318;PolyBezier (hdc, bpt, 4);bpt[0].x = 280;bpt[0].y = 420;bpt[1].x = 276;bpt[1].y = 351;bpt[2].x = 344;bpt[2].y = 370;bpt[3].x = 383;bpt[3].y = 300;PolyBezier (hdc, bpt, 4);bpt[0].x = 280;bpt[0].y = 420;bpt[1].x = 270;bpt[1].y = 418;bpt[2].x = 260;bpt[2].y = 436;bpt[3].x = 261;bpt[3].y = 440;PolyBezier (hdc, bpt, 4);bpt[0].x = 350;bpt[0].y = 322;bpt[1].x = 318;bpt[1].y = 347;bpt[2].x = 235;bpt[2].y = 345;bpt[3].x = 261;bpt[3].y = 440;PolyBezier (hdc, bpt, 4);EndPaint (hwnd, &ps);return 0;case WM_DESTROY:PostQuitMessage (0);return 0;}return DefWindowProc (hwnd, message, wParam, lParam);}