Solved

Erasing canvas images to transparent

Posted on 2002-04-29
7
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 9

Expert Comment

by:ginsonic
ID: 6977671
listening
0
 
LVL 2

Accepted Solution

by:
PeterLarsen earned 50 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi application Soap connection 5 151
Delphi inherited method 6 86
Delphi: making a BW image transparent 10 135
"Could not obtain OLE control window handle" under Delphi XE8 8 74
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

738 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