Transparent Controls

S

Steve Koon

Any thoughts on getting this project to work or suggesting another method
would be appreciated.

Steve

==========================================

Project:

A Windows Form which acts as a Whiteboard. The Form contains 3
layered UserControls. The upper most control frame is the 'event_frame'
which handles mouse events. (This frame will handle further events in the
future). The middle frame is the 'drag_frame', which draws out mouse move
events.like dragging mouse boxes on a windows desktop. The bottom frame is
the 'render_frame' which is the main canvas of the whiteboard. On object
creation (after a successful mouse down,drag,up event) the render_frame
would contain the drawing of all current objects.



Problem:


We would like to have all control frames transparent, and yet still be able
to see the contents of the underlying control frames. Currently when one
control is set completely transparent.all controls appear fully transparent
and the underlying form displays through.


Our completed project should have a total transparent event_frame that you
could see through to the render_frame. Upon click on the event_frame.the
event_frame is hidden and the drag_frame becomes visible. (assuming the
mouse is in a down state) You are able to see through the drag_frame to the
render_frame and its contents. As the user drags out a bounding box, the box
is drawn on the drag_frame. Upon mouseup the object is created, the
drag_frame is cleared & hidden, the object is drawn on the render_frame and
the event_frame is visible again.



Solution:

We have successfully set the control styles to allow transparent background
colors and overridden the OnPaintBackground events. This provides some of
the effect we would like to achieve, however we still cannot see the
contents of the control frames underneath each other.



Secondary Question:

Is there any way to flush out, clear or dispose of a Graphics object
without using the .Clear(Color) method? This method simply fills the entire
object with a given color, we would like a way to simply clear the data in
the graphics object and start anew.or something similar to using
*.Clear(Color.FromArgb( 0, Color.White )) This uses an Alpha value of 0 to
hopefully achieve a completely transparent effect.but when we use this the
screen is completely Black.not transparent.
 
R

Rodrigo Ferreira

try this,

this.SetStyle(ControlStyles.SupportsTransparentBackColor,true);
this.BackColor = Color.Transparent;
 
S

Steve Koon

Unfortunately this was one of the very first things We did, and it's of no
use. The problem isn't necessarily making it 'transparent' but to function
in a transparent fashion. Using this, the effect is seeing through
EVERYTHING all the way down to the form, not what we want. We would like the
effect to stop at each layer.

However, We believe using Panels instead of User Controls may be the way to
go. It's a little bit more trouble to integrate, since they don't inherit as
User Controls do, but they seem to behave just like we would like. I will
let you know how it goes.

Steve
 
F

Frank Hileman

Best to use graphical objects that are not controls ("lite controls"), and
handle painting and hit testing in a single control. This works well if it
is a true whiteboard type of application. A set of Windows Forms controls
will not behave properly this way.


Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top