You can draw simple shapes with the WinGDI Class
.
Here is a simple sample :
void drawShapes()
{
WinGDI winGDI;
Int brush, height, width;
;
//myWindow being the FormWindowControl
height = myWindow.heightValue()/2;
width = myWindow.widthValue()/2;
myWindow.lockDC();
winGDI = new WinGDI(myWindow.hDC());
brush = winGdi.createSolidBrush(WinAPI::RGB2int(0, 0, 255));
winGDI.fillRect(0, 0, width, height, brush);
winGDI.deleteObject(brush);
winGDI.ellipse(0, 0, width, height);
brush = winGdi.createSolidBrush(WinAPI::RGB2int(255, 0, 0));
winGDI.fillRect(width, height, 2*width, 2*height, brush);
winGDI.deleteObject(brush);
myWindow.UnlockDC();
}
I assume you got something similar.
Now if you just call it once in the form's init
, the drawing's will be erased as soon as the paint
method of the window control is called (and it's called pretty often).
So the easiest way is to call it in the paint
method of the window. This way every time myWindow's content is redrawn, your shapes are too.
You can also force the redrawing of the shapes at a (short) regular time interval like the Tetris Tutorial does (look at the cycle
method) using setTimeout
but it may be overkill for static content.
You should now have this