[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Erasing canvas images to transparent

Posted on 2002-04-29
7
Medium Priority
?
274 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Technology Partners: 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
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…
Suggested Courses

650 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