Пример #1
0
BOOL  DrawGradientRect(HDC hdc, 
		       RECT *lprc, 
		       COLORREF color1, 
		       COLORREF color2,
	       	       int iEdgeWidth )
{
	int x0 = lprc->left;
	int y0 = lprc->top;

	int x1 = lprc->right;
	int y1 = lprc->bottom;

	int d = iEdgeWidth;

	GradientRectangle(hdc, x0, y0, x1, y1, color2, color1, 45);
	GradientRectangle(hdc, x0+d, y0+d, x1-d, y1-d, color1, color2, 45);	

	return TRUE;
}
Пример #2
0
void Demo_AreaFill(HDC hDC, const RECT * rcPaint, int width, int height)
{
	const COLORREF c0 = RGB(0x20, 0x20, 0x20);
	const COLORREF c1 = RGB(0xF0, 0xF0, 0x20);

	for (int i=0; i<4; i++)
		GradientRectangle(hDC, 1000+1100*i, 500, 2000+1100*i, 1500, c0, c1, i*450);

	for (i=0; i<4; i++)
		SymGradientRectangle(hDC, 1000+1100*i, 1600, 2000+1100*i, 2600, c0, c1, i*450);

	for (i=0; i<4; i++)
		CornerGradientRectangle(hDC, 1000+1100*i, 2700, 2000+1100*i, 3700, c0, c1, i);

	CenterGradientRectangle(hDC, 5600, 1500, 6600, 2500, c0, c1);
	CenterGradientRectangle(hDC, 5600, 2600, 6600, 3600, c1, c0);

	//  Buttons
	RoundRectButton(hDC, 0,    4000,  800, 4800,   0, 100, RGB(0x20, 0x20, 0x20), RGB(0xF0, 0xF0, 0x20));
	RoundRectButton(hDC, 1000, 4000, 1800, 4800, 400, 100, RGB(0xF0, 0x20, 0x20), RGB(0x20, 0xF0, 0x20));
	RoundRectButton(hDC, 2000, 4000, 2800, 4800, 800, 100, RGB(0xFF, 0xFF, 0x20), RGB(0x20, 0x20, 0xF0));
	
	   GradientRectangle(hDC, 0, 5000, 2000, 6000, RGB(0xFF, 0x0, 0), RGB(0, 0, 0xFF), 0);
	HLSGradientRectangle(hDC, 0, 6200, 2000, 7200, RGB(0xFF, 0x0, 0), RGB(0, 0, 0xFF), 200);

	RadialGradientFill(hDC, 3200, 6300, 3200    , 6300   ,  1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 8);
	RadialGradientFill(hDC, 5300, 6300, 5300-300, 6300-600, 1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 16);
	RadialGradientFill(hDC, 7400, 6300, 7400-300, 6300+300, 1000, RGB(0xFF, 0xFF, 0xFF), RGB(0, 0, 0xFF), 256);

	{
		RECT r = { 7000, 500, 8500, 500+1500 };

		KGDIObject blue(hDC, CreatePen(PS_SOLID, 1 * ONEINCH/72, RGB(0, 0, 0xFF)));
		KGDIObject yellow(hDC, CreateSolidBrush(RGB(0xFF, 0xFF, 0)));
	
		Rectangle(hDC, 7000, 500, 8500, 500+1500);
		
		BrickPatternFill(hDC, 7000,  500, 8500,	 500+1500, 150, 150);
		BrickPatternFill(hDC, 7000, 2100, 8500, 2100+1500, 100, 100);
	}

	KLogFont logfont(- 8 * ONEINCH / 72, "Tahoma");
	KGDIObject font(hDC, logfont.CreateFont());

	{
		SelectObject(hDC, GetStockObject(NULL_PEN));
	
		typedef enum { GAP = 1200 };

		for (int hs= HS_HORIZONTAL; hs<=HS_DIAGCROSS; hs++)
		{
			HBRUSH hBrush = CreateHatchBrush(hs, RGB(0, 0, 0xFF));
			HGDIOBJ hOld  = SelectObject(hDC, hBrush);

			SetBkColor(hDC, RGB(0xFF, 0xFF, 0));
			Rectangle(hDC, hs*GAP, 8000, hs*GAP+890, 8890);

			SetBkColor(hDC, RGB(0xFF, 0xFF, 0xFF));
		
			SetTextAlign(hDC, TA_CENTER);
			TextOut(hDC, hs*GAP+880/2, 8980, HS_Names[hs-HS_HORIZONTAL], _tcslen(HS_Names[hs-HS_HORIZONTAL]));

			SelectObject(hDC, hOld);
			DeleteObject(hBrush);
		}
	}

	{
		HINSTANCE hCards = LoadLibrary("cards.dll");

		for (int i=0; i<3; i++)
	{
		HBRUSH hBrush;
		int    width, height;

		switch ( i )
		{
			case 0:
				{
					HBITMAP hBitmap = LoadBitmap(hCards, MAKEINTRESOURCE(52));
					BITMAP  bmp;

					GetObject(hBitmap, sizeof(bmp), & bmp);
					width = bmp.bmWidth; height = bmp.bmHeight;

					hBrush = CreatePatternBrush(hBitmap);
					DeleteObject(hBitmap);
				}
				break;

			case 1:
				{
					HRSRC hResource = FindResource(hCards, MAKEINTRESOURCE(52-14), RT_BITMAP);
					HGLOBAL hGlobal = LoadResource(hCards, hResource);
	
					hBrush  = CreateDIBPatternBrushPt(LockResource(hGlobal), DIB_RGB_COLORS);
					width   = ((BITMAPCOREHEADER *) hGlobal)->bcWidth; // old DIB format
					height  = ((BITMAPCOREHEADER *) hGlobal)->bcHeight;// old DIB format
				}
				break;

			case 2:
				{
					HRSRC hResource = FindResource(hCards, MAKEINTRESOURCE(52-28), RT_BITMAP);
					HGLOBAL hGlobal = LoadResource(hCards, hResource);

					hBrush  = CreateDIBPatternBrush(hGlobal, DIB_RGB_COLORS);
					width   = ((BITMAPCOREHEADER *) hGlobal)->bcWidth;  // old DIB format
					height  = ((BITMAPCOREHEADER *) hGlobal)->bcHeight; // old DIB format
				}
		}
		
		HGDIOBJ hOld  = SelectObject(hDC, hBrush);

		POINT P = { i*1400+200 + width*10*i/4, 10000 + height*10*i/4 };
		LPtoDP(hDC, &P, 1);
		SetBrushOrgEx(hDC, P.x, P.y, NULL); // make sure cards aligned with rectangle
	
		Rectangle(hDC, i*1400+200, 10000, i*1400+200+width*30/2+1, 10000+height*30/2+1);
	
		SelectObject(hDC, hOld);
		DeleteObject(hBrush);

	}
	}

}