Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 18th, 2004, 01:00 AM
Registered User
Join Date: Dec 2004
Location: , , .
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!

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 06:33 PM.

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