Trouble with Canvas->Pen->Width

Trouble with Canvas->Pen->Width

Post by Dmitry Zagovayl » Thu, 24 Jun 1999 04:00:00



OK. I set the
Canvas->Pen->Style
property for psDash or other (not psSolid)

After that I change Width property (big then 1) and draw anything - I see SOLID line.

Who know- what happen's?
And how can I solve this problem (for display drawing& for printing)

Thank's.
Slam.

 
 
 

Trouble with Canvas->Pen->Width

Post by Alan McIntyr » Thu, 24 Jun 1999 04:00:00



> OK. I set the Canvas->Pen->Style
> property for psDash or other (not psSolid)

> After that I change Width property (big then 1) and draw anything - I see SOLID line.

Have you tried setting the style again after you change the width?
There's probably some underlying reason why the VCL changes the style
when you set the width, and maybe you'll just have to reset the style
whenever you change the width.

Hope this helps,
Alan McIntyre

http://norfolkgraphics.com

 
 
 

Trouble with Canvas->Pen->Width

Post by Owen Lawrenc » Thu, 24 Jun 1999 04:00:00


I believe it's documented that non-solid styles only work with width equal
to 1.  I've asked this question before and nobody had a solution.

  - Owen -

Quote:> property for psDash or other (not psSolid)

> After that I change Width property (big then 1) and draw anything - I see
SOLID line.

> Who know- what happen's?
> And how can I solve this problem (for display drawing& for printing)

 
 
 

Trouble with Canvas->Pen->Width

Post by Dmitry Zagovayl » Fri, 25 Jun 1999 04:00:00


Hi, Alan McIntyre.
Thank's, BUT
See the code
problem are not solved
what are your think about it ?
TForm1 *Form1;
int x, y;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{

Quote:}

//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
  x = random(Screen->Width - 10);
  y = random(Screen->Height - 10);
  Canvas->Pen->Color = (Graphics::TColor) random(65535);

 //!!!!!!!!Changing the Width

 Canvas->Pen->Width=random(5)+2; // not 0 or 1

 //After that changing the style- but if width>1
 //we are see the Solid line!

 switch (random(4)+1) //from 1 up to 4
  {
//    case 0: Canvas->Pen->Style = psSolid; break;

    case 1: Canvas->Pen->Style = psDash; break;
    case 2: Canvas->Pen->Style = psDot; break;
    case 3: Canvas->Pen->Style = psDashDot; break;
    case 4: Canvas->Pen->Style = psDashDotDot; break;
  }
  Canvas->Rectangle(x, y, x + random(400), y + random(400));

Quote:}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormActivate(TObject *Sender)
{
  WindowState = wsMaximized;
  Timer1->Interval = 50;
  randomize();

Quote:}

//---------------------------------------------------------------------------
> Have you tried setting the style again after you change the width?
> There's probably some underlying reason why the VCL changes the style
> when you set the width, and maybe you'll just have to reset the style
> whenever you change the width.

> Hope this helps,
> Alan McIntyre

> http://norfolkgraphics.com

 
 
 

Trouble with Canvas->Pen->Width

Post by Damon Chandle » Fri, 25 Jun 1999 04:00:00


Hi Slam,

Quote:> See the code
> problem are not solved
> what are your think about it ?

This is a Windows limitation.  Only psInsideFrame, psSolid, and psClear will
work with widths greater than one.  Have a look in the API help file under
"Create Pen."  It is explained in the "Reamrks" section.

Good luck.

--------------------------------------
Damon Chandler

http://bcbcaq.freeservers.com
Answers to <Commonly Asked Questions>

 
 
 

Trouble with Canvas->Pen->Width

Post by Wojciech Komornick » Mon, 28 Jun 1999 04:00:00



Quote:> Hi Slam,
> > See the code
> > problem are not solved
> > what are your think about it ?

> This is a Windows limitation.  Only psInsideFrame, psSolid, and psClear
will
> work with widths greater than one.  Have a look in the API help file under
> "Create Pen."  It is explained in the "Reamrks" section.

I have read the REMARKS section and have found the same "limitation"
explained in Petzold's book and in the Windows SDK.  Yet, there are
applications (for example MS Word drawing routines) which allow one to draw
dashed and dotted lines which are thicker than one pixel.

By the way, the limitation is a Win95 limitation.  This is not a limitation
in Windows NT.

Wojciech Komornicki