Solved

Erasing canvas images to transparent

Posted on 2002-04-29
7
266 Views
Last Modified: 2010-04-04
I have two layered Paintboxes on top of a black panel, making a graph of sorts with little square nodes and connecting lines. I want the user to click and drag the nodes, so I need to erase and re-plot them repeatedly. Likewise with the lines. I rely on the initial transparency of the paintboxes to see what is beneath. How do I make existing pen and brush images transparent? Drawing the panel color simply obscures everything.
0
Comment
Question by:HorridMan
  • 3
  • 3
7 Comments
 
LVL 9

Expert Comment

by:ginsonic
Comment Utility
listening
0
 
LVL 2

Accepted Solution

by:
PeterLarsen earned 50 total points
Comment Utility
You dont say anything about how you paint on the canvas.

Anyway, TPaintBox is inherited from TGraphicControl and if i remember right, WM_ERASEBKGND isn't directed to TPaintBox - which means, you must draw everything through WM_PAINT (OnPaint).

Every time you want to draw a 'node being draged' you alså must re-draw the background on the 'background paintbox'.

I can't see, from your question, whether this is your problem or not.

TPaintBox dont provide you with a 'cached canvas' (a canvas that automatically update itself when needed), so you gotta do it yourself everytime.

Hope this help.
Peter
0
 

Author Comment

by:HorridMan
Comment Utility
PeterLarsen -
  Yes, redrawing the whole thing does get rid of the bits that I want to discard. Can you tell me how best to do this. I've tried calling TPaintBox.Paint, as per the help file, but Delphi itself takes this as an undeclared identifier. Is there another way to redraw?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:HorridMan
Comment Utility
Please ignore my last comment. I've worked out for myself how to trigger the OnPaint event. Just set the Visible property to FALSE and then set it to TRUE. This creates nice, smooth animation. But if there's a less hack-like solution I'd still like to learn about it.
0
 
LVL 2

Expert Comment

by:PeterLarsen
Comment Utility
Hi HorridMan and thanks for the points,

Sorry my late reply.

Try TPaintBox.Invalidate or TPaintBox.Update.

Regards
Peter
0
 
LVL 2

Expert Comment

by:PeterLarsen
Comment Utility
There are also a different way to do this. Its a little bit more complicated than the above solution.
0
 

Author Comment

by:HorridMan
Comment Utility
Thank-you, Peter.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Master Detail with TADODataset 4 94
Delphi cmd execution 6 40
Help on project with Soap 10 42
Delphi selector screen 2 57
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now