[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Erasing canvas images to transparent

Posted on 2002-04-29
7
Medium Priority
?
275 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
ID: 6977671
listening
0
 
LVL 2

Accepted Solution

by:
PeterLarsen earned 150 total points
ID: 6977829
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
ID: 6979498
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:HorridMan
ID: 6979526
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
ID: 6982792
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
ID: 6982803
There are also a different way to do this. Its a little bit more complicated than the above solution.
0
 

Author Comment

by:HorridMan
ID: 6985269
Thank-you, Peter.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

830 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