Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pen settings not displaying 1

Status
Not open for further replies.

Fluke026

Programmer
Aug 20, 2002
32
0
0
US
Hello,

I have the following code:
Code:
   ImMap.Canvas.Pen.Style:= psDash;
   i:= LeftBounds + 10;
   while (i < RightBounds) do begin
      ImMap.Canvas.MoveTo(i, TopBounds);
      ImMap.Canvas.LineTo(i, BottomBounds);
      i:= i + 10;
   end; {while}

The problem is that no matter what I set the pen style to, it always draws a solid line. The only problem seems to be with the Pen.Style. The lines draw just fine (except as psSolid).

What am I missing?

Frank
 
Not sure what you expected to see, but perhaps your drawing space is too small.

Your code works fine for my test on a 200 x 200 canvas.

Try using psDot instead of psDash.
 
The Image.canvas is 410x540. psDot didn't make a difference. Is there a problem with these commands in D5 even though I found them in the D5 help? I hope to see a grid composed of dashes (dots would be fine, too).
 
Maybe if you show more of your code someone else here can help you. I don't know what else to suggest. As I posted, it draws vertical dashed lines for me (or dotted lines with psDot). I'm using D5.
 
Here is the procedure in question:

Code:
procedure TMain.CleanMap;
var
   BitMap: TBitMap;
   i: integer;
begin
   Bitmap:= TBitmap.Create;
   Bitmap.Width:= ImMap.Width;
   Bitmap.Height:= ImMap.Height;
   ImMap.Picture.Graphic:= Bitmap;

   //draw a border 10 in from the edge all the way around
   ImMap.Canvas.Brush.Color:= clBlack;
   ImMap.Canvas.FrameRect(Rect(WWall, NWall, EWall, SWall));
   BitMap.Free;   //release resources when no longer needed
   ImMap.canvas.pen.style:= psDash;
   //draw the up and down grid lines
   i:= WWALL + 10;
   while (i <= (EWALL-10)) do begin
      ImMap.Canvas.MoveTo(i, NWALL);
      ImMap.Canvas.LineTo(i, SWALL);
      i:= i + 10;
   end;
   //draw the side to side grid lines
   i:= NWALL + 10;
   while (i <= (SWALL-10)) do begin
      ImMap.Canvas.MoveTo(i, WWALL);
      ImMap.Canvas.LineTo(i, EWALL);
      i:= i + 10;
   end;
end;

Like the man above said, it should work fine, but from my compilation it doesn't. Any ideas on why the psDash is being ignored?

Frank Luke
 
It looks like you need to add the statement:

ImMap.Canvas.Brush.Color := clWhite;

before setting the style, to re-set the setting from clBlack you used for the FrameRect.

Also, you will eventually notice that the drawing of the side to side have the x/y parms reversed. It should be:

ImMap.Canvas.MoveTo(WWALL,i);
ImMap.Canvas.LineTo(EWALL,i);
 
Thank you! It works great! Have a star. I am always amazed at myself for missing the simple things but catching the hard ones with little problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top