[WinAPI] API 1 [桌面上画一个简单彩色图形]

 

 1 #include<Windows.h>
 2 void GdiOut(HDC hdc);
 3 int WINAPI WinMain(HINSTANCE hInstance,
 4                    HINSTANCE hPrevInstance,
 5                    LPSTR lpCmdLine,
 6                    int nCmdShow)
 7 {
 8     HDC hdc=GetDC(NULL);
 9     GdiOut(hdc);
10     ReleaseDC(NULL,hdc);
11 }
12 void GdiOut(HDC hdc)
13 {
14     HPEN hpen;
15     HBRUSH hbrush;
16     BYTE bRed=0;
17     BYTE bGreen=0;
18     BYTE bBlue=0;
19     COLORREF cPen=RGB(bRed,bGreen,bBlue);
20     COLORREF cBrush=RGB(233,GetGValue(cPen),255);
21     hpen=CreatePen(PS_SOLID,10,cPen);
22     hbrush=CreateSolidBrush(cBrush);
23     SelectObject(hdc,hbrush);
24     LineTo(hdc,500,500);
25     SelectObject(hdc,hpen);
26     Rectangle(hdc,200,200,500,500);
27     DeleteObject(hpen);
28     DeleteObject(hbrush);
29 }

 

posted @ 2014-03-05 02:23  beautifulzzzz  阅读(936)  评论(0编辑  收藏  举报