• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

GDI+: GdipDrawRectangle

Started by José Roca, June 23, 2008, 05:36:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example defines a pie and then fills it.

C++


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

   // Create a Pen object.
   Pen blackPen(Color::Black, 3);

   // Define the rectangle.
   REAL x = 0.0f;
   REAL y = 0.0f;
   REAL width = 200.0f;
   REAL height = 200.0f;

   // Draw the rectangle.
   graphics.DrawRectangle(&blackPen, x, y, width, height);
}


PowerBASIC


SUB GDIP_DrawRectangle (BYVAL hdc AS DWORD)

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

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a Pen
   hStatus = GdipCreatePen1(GDIP_ARGB(255,0, 0, 0), 3, %UnitPixel, pPen)

   ' // Define the rectangle.
   x = 10.0!
   y = 10.0!
   nWidth = 200.0!
   nHeight = 200.0!

   ' // Draw the pie
   hStatus = GdipDrawRectangle(pGraphics, pPen, x, y, nWidth, nHeight)

   ' // Cleanup
   IF pPen THEN GdipDeletePen(pPen)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB