Pelles C forum

C language => Pocket PC and Smartphone questions => Topic started by: jasch212 on November 23, 2008, 04:52:29 PM

Title: fillout a triangel with a colour
Post by: jasch212 on November 23, 2008, 04:52:29 PM
hi,
how can i fill the traingel with a color?

...
// Create a pen, one pixel, bright red.
  HPEN hpen = CreatePen(PS_SOLID, 1, RGB(255,0,0));
// Select the pen into the 'Device context' and remember the previous pen.
  HPEN hpenSave = SelectObject(ps.hdc, hpen);
// Array of points to 'connect'.
  POINT apt[] = {
  { 20,20 },
  { 50,20 },
  { 50,50 },
  { 20,20 }
  };

// Draw lines between the points in the 'apt' array.
  Polyline(ps.hdc, apt, sizeof(apt) / sizeof(apt[0]));

thanks for answers.
Title: Re: fillout a triangel with a colour
Post by: Synfire on November 23, 2008, 08:20:51 PM
Try changing it to something like this.

Code: [Select]
HBRUSH hBrush = CreateSolidBrush( RGB(255,0,0) );
SelectObject( ps.hdc, hBrush );
POINT apt[] = {
  { 20,20 },
  { 50,20 },
  { 50,50 }
};
Polygon( ps.hdc, apt, 3 );

Hope that works..  ???
Title: Re: fillout a triangel with a colour
Post by: jasch212 on November 24, 2008, 07:31:46 PM
hi Synfire,
thank you for the fast answer.
it work's very fine! :)

jasch212