Solved

Erasing canvas images to transparent

Posted on 2002-04-29
7
267 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 105
Newbie Thread Programming 1 139
Correct Component for Shopping Cart. 2 96
Multiple image collision 13 69
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 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

17 Experts available now in Live!

Get 1:1 Help Now