|
#include "stdafx.h"
#include "CDibPieza.h"
#define MAXANCHO 5
BEGIN_MESSAGE_MAP(CDibPieza, CStatic)
ON_WM_PAINT()
END_MESSAGE_MAP()
void CDibPieza::OnPaint()
{
if (!pieza) return;
CRect rect;
GetClientRect(&rect);
CPaintDC dc (this);
int padding = 20;
int anchocuad = (rect.right - padding * 2) / MAXANCHO;
int xbase = (rect.right - anchocuad * pieza->Ancho) / 2;
int ybase = (rect.bottom - anchocuad * pieza->Alto) / 2 + anchocuad * pieza->Alto;
COLORREF color = RGB(255,255,255);
CBrush fondo(color);
dc.FillRect(rect,&fondo);
CRect rfill;
int leftdato, topdato;
CBrush fondopieza(pieza->GetColor(idPInfo,CantPiezas));
dc.SelectObject(fondopieza);
CPen pen(PS_SOLID, 1, RGB(50,50,50));
dc.SelectObject(pen);
for (int i=1;i<=pieza->Alto;i++)
{
for (int j=1;j<=pieza->Ancho;j++)
{
if (pieza->GetValue(i,j))
{
leftdato = xbase + (j-1)*anchocuad;
topdato = ybase - (i-1)*anchocuad;
rfill = CRect(leftdato, topdato,leftdato + anchocuad,topdato - anchocuad);
dc.Rectangle(rfill);
//dc.FillRect(rfill,&fondopieza);
}
}
}
dc.RestoreDC(-1);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
System developer from Argentina.
Programmed in VB 5,6,.NET, C#, Java, PL-SQL, Transac-SQL, C, C++ and even some "calculator" language.
Love to build small, useful applications.
Usually building big and complicated apps based on solid, reliable components.
Hobbies: reading, photography, chess, paddle, running.