• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipFillRectangle

Started by José Roca, June 23, 2008, 06:17:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example defines a rectangle and fills it.

C++


VOID Example_FillRectangle4(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a SolidBrush object.
   SolidBrush blackBrush(Color(255, 0, 0, 0));

   // Define the rectangle.
   REAL x = 0.5f;
   REAL y = 0.5f;
   REAL width = 100.8f;
   REAL height = 100.8f;

   // Fill the rectangle.
   graphics.FillRectangle(&blackBrush, x, y, width, height);
}


PowerBASIC


SUB GDIP_FillRectangle (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pBrush AS DWORD
   LOCAL x AS SINGLE
   LOCAL y AS SINGLE
   LOCAL nWidth AS SINGLE
   LOCAL nHeight AS SINGLE

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a SolidBrush
   hStatus = GdipCreateSolidFill(GDIP_ARGB(255, 0, 0, 0), pBrush)

   ' // Define the rectangle.
   x = 0.5!
   y = 0.5!
   nWidth = 100.8!
   nHeight = 100.8!

   ' // Fill the rectangle.
   hStatus = GdipFillRectangle(pGraphics, pBrush, x, y, nWidth, nHeight)

   ' // Cleanup
   IF pBrush THEN GdipDeleteBrush(pBrush)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB