//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HPEN hpen, hpenOld;
HBRUSH hbrush, hbrushOld;
HDC hdc = this->Canvas->Handle;
// Red pen for the border
hpen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
// Blue brush for the interior.
hbrush = CreateSolidBrush(RGB(0, 0, 255));
// Select the new pen and brush then draw a rectangle.
hpenOld = SelectObject(hdc, hpen);
hbrushOld = SelectObject(hdc, hbrush);
Rectangle(hdc, 100,100, 400,250);
// After using your objects, delete them and restore the originals
SelectObject(hdc, hpenOld);
DeleteObject(hpen);
SelectObject(hdc, hbrushOld);
DeleteObject(hbrush);
}
//---------------------------------------------------------------------------
|