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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

not drawing over panels and radios? 1

Status
Not open for further replies.

CADTenchy

Technical User
Dec 12, 2007
237
GB
I have a form where I'm loading a bitmap (a map actually) and drawing over it with simple MoveTo and LineTo commands.
I also have a TPanel at the top to contain some radio buttons to select which map to use.

I'm plotting lines from essentially one lat and long to another.

This is working fine except when to LineTo takes it out of the range of the particular map and up toward panel at the top, some bits of line are being drawn over either the panel or radios.

Now I don't care less if the lineto point lies off the map, as the direction still shows.
I didn't want to do extra sums to truncate the line if it's going over the panel etc, so is there a way to make the panel and components on it show over the drawn lines, or clean them away after plotting?

I tried repainting the panel after drawing, but that did weird things!

For info, I'm loading the bitmat with this method:
Code:
BMPbackground := TBitmap.Create;
BMPbackground.LoadFromFile(Mapname);
Canvas.Draw( 0, 32, BMPbackground ); // 32 pixels down for the top panel


Steve (Delphi 2007 & XP)
 
You might try drawing the map onto a TPanel or TImage?

----------
Measurement is not management.
 
thanks for reply Glenn.
I've tried both now.

I couldn't see the light drawing the image on a Tpanel, but I did have some success with Timage.
However, I did have some issues.

I didn't mention in OP that I actually switchin between 2 images (possibly more later). Drawing to form I had no prob resizing the form to new map.
But when doing so with Timage I got an effect like when a TV lost it's vertical hold.

I couldn't work it out so I decided plan A was so close I'd write the limiting code after all.
During testing for this I noticed I was getting into a permanent loop, I think I worked that out but would like to check.
I'm callin the line drawing proc in OnFormPaint, so if the form is moved or covered etc the desired is repainted.
To check some numbers I added a line to display a number value in a Tlabel inside the drawing proc.
When I did that I could see the label being updated continuously.

Is this because I am forcing a call to OnFormPaint each time I set the label?
Removing the label call should return the form to a non-looping state?

Steve (Delphi 2007 & XP)
 

Just a note to say thanks Glenn.

I should have persevered with your advice.

Having tried TImage as I said above and having troubles, I went back to plan A, but I struggled on doing it a worse way, eventually getting no further forward.

What I did yesterday was start a brand new project and do a simple test app using TImage, and got it doing exactly what I want with fewer procedures and calls required.

Moral learned this time is to persevere with trying the advice offered.


Steve (Delphi 2007 & XP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top