Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 18th, 2004, 01:00 AM
Registered User
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Transparency and repainting

Hi everyone!

I'm new to these forums, and thought I'd sign up because I need some help with C# programming. I'm just a hobbyist programmer, something I like to do in my spare time to keep myself from going insane. ;) I've been coding in C# for about a month now, so I'm not a total newb, but I'm no expert either. :)

Anyways, onto my issue.
I've found a couple of websites that show how to do control transparency, i.e. how to see what's behind the control. This works great, but I've encountered a slight problem. When moving this control on top of another transparent control, they don't get displayed properly. This is due to the way the redrawing is handled, not to mention the fact that a Paint even is only sent when the underlying control is reveled, NOT when it's being covered. In this case, I need a Paint event to be sent regardless. I've tried forcing an invalidation, but it still doesn't look right.

Here's the code I'm using in my inherited Panel class (which is the drawing surface I'm using):

        protected override CreateParams CreateParams
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x00000020;
                return cp;

        protected void InvalidateEx()
            if (Parent == null)
            Rectangle rc = new Rectangle(this.Location, this.Size);
            Parent.Invalidate(rc, true);

        protected override void OnPaintBackground(PaintEventArgs pevent)
Using these 3 I'm able to achieve a nice transparency effect, but only if the controls stay where they are; if they move around, this causes problems.

Basically, I'm trying to make a simple CAD program, and I want to be able to manipulate transparent objects. I'd like them to be transparent, so that if you place two objects on top of each other, you can see the bottom object through the top. If anyone has any resources on this sort of thing, I would greatly appreciate any help!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitmap Transparency tahcue C++ Programming 0 December 19th, 2007 07:45 PM
Programming Repainting Control mrafaqi VB How-To 0 March 28th, 2006 04:39 PM
ImageList/transparency problem jacob C# 0 February 27th, 2006 08:37 AM
PNG Transparency in IE richard.york Javascript 4 January 19th, 2004 08:26 PM
Transparency Problem blah VB.NET 2002/2003 Basics 0 October 30th, 2003 02:40 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.