Board index » cppbuilder » drawing a rectangle

drawing a rectangle


2007-10-04 03:07:05 PM
cppbuilder2
Hi,
I'm trying to draw a simple rectangle with the following code :
...
this->Canvas->Pen->Color = TColor(0x00FFAAAA);
this->Canvas->Pen->Width = 1;
this->Canvas->Rectangle(0,0,this->Width, this->Height);
...
this works perfectly.
however, if for some reason i do not want to draw the rectangle border
but only the contents (the brush), i do :
...
//this->Canvas->Pen->Color = TColor(0x00FFAAAA);
this->Canvas->Pen->Width = 0;
this->Canvas->Rectangle(0,0,this->Width, this->Height);
...
but anyway, it draws the border...
where is the problem ?
thx.
RAF
 
 

Re:drawing a rectangle

R.A.F. schreef:
Quote
Hi,

I'm trying to draw a simple rectangle with the following code :
...
this->Canvas->Pen->Color = TColor(0x00FFAAAA);
this->Canvas->Pen->Width = 1;
this->Canvas->Rectangle(0,0,this->Width, this->Height);
...

this works perfectly.
however, if for some reason i do not want to draw the rectangle border
but only the contents (the brush), i do :
...
//this->Canvas->Pen->Color = TColor(0x00FFAAAA);
this->Canvas->Pen->Width = 0;
this->Canvas->Rectangle(0,0,this->Width, this->Height);
...

but anyway, it draws the border...
where is the problem ?

thx.

RAF
Try setting the penstyle to psClear
this->Canvas->Pen->Style = psClear;
Eelke
 

Re:drawing a rectangle

In article <47049117$ XXXX@XXXXX.COM >,
Hi RAF
XXXX@XXXXX.COM says...
Quote
Hi,

this->Canvas->Pen->Width = 0;
You don't need the this pointer
You can write only:
Canvas->Pen->Width = 0;
Kind regards
Asger
 

{smallsort}

Re:drawing a rectangle

You can use the Canvas->FillRect function.
Asger Jørgensen schrieb:
Quote
In article <47049117$ XXXX@XXXXX.COM >,
Hi RAF

XXXX@XXXXX.COM says...
>Hi,
>
>this->Canvas->Pen->Width = 0;

You don't need the this pointer
You can write only:

Canvas->Pen->Width = 0;

Kind regards
Asger
 

Re:drawing a rectangle

"R.A.F." < XXXX@XXXXX.COM >wrote in message
Quote
this->Canvas->Pen->Width = 0;
You can't set the Width below 1. This is stated in the TPen documentation:
"If Width is set to a value less than 1, the pen is given a Width of 1."
Quote
but anyway, it draws the border...
Rectangle() is supposed to always draw a border. The TCanvas documentation
says as much:
"Use Rectangle to draw a rectangle using Pen and fill it with Brush...To
fill a rectangular region without drawing the boundary in the current pen,
use FillRect."
Gambit
 

Re:drawing a rectangle

And is there a method to draw a 3D rectangle or should i play with
lines, rectangle and fillrect ?
R.A.F. wrote:
Quote
Hi,

I'm trying to draw a simple rectangle with the following code :
...
this->Canvas->Pen->Color = TColor(0x00FFAAAA);
this->Canvas->Pen->Width = 1;
this->Canvas->Rectangle(0,0,this->Width, this->Height);
...

this works perfectly.
however, if for some reason i do not want to draw the rectangle border
but only the contents (the brush), i do :
...
//this->Canvas->Pen->Color = TColor(0x00FFAAAA);
this->Canvas->Pen->Width = 0;
this->Canvas->Rectangle(0,0,this->Width, this->Height);
...

but anyway, it draws the border...
where is the problem ?

thx.

RAF
 

Re:drawing a rectangle

in fact i would like to recreate the same look as the BevelOuter,
BevelEdge and so on, but in 1 property :-)
 

Re:drawing a rectangle

"R.A.F." < XXXX@XXXXX.COM >wrote in message
Quote
And is there a method to draw a 3D rectangle or should
i play with lines, rectangle and fillrect ?
Look at the Frame3D() function.
Gambit