PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET Transparent Form surface

Reply

Transparent Form surface

 
Thread Tools Rate Thread
Old 21-05-2006, 12:28 AM   #1
tommaso.gastaldi@uniroma1.it
Guest
 
Posts: n/a
Default Transparent Form surface


I found useful to use transparent controls like:

'----------------------------------------------------------------------------------
Public Class UserControlTransp
Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "
....
#End Region

Protected Overrides ReadOnly Property CreateParams() As
System.Windows.Forms.CreateParams
Get
Dim MyParams As CreateParams = MyBase.CreateParams()
MyParams.ExStyle = MyParams.ExStyle Or &H20
Return MyParams
End Get
End Property

Protected Overrides Sub OnPaintBackground(ByVal e As
System.Windows.Forms.PaintEventArgs)
' for transparency
End Sub

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
' Any drawing here ...
ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(10, 10,
200, 100), Border3DStyle.Etched)
e.Graphics.FillEllipse(New SolidBrush(Color.FromArgb(100, 120,
200, 255)), New Rectangle(30, 30, 100, 100))
End Sub

End Class

'----------------------------------------------------------------------------------

this allows to draw on a trasparent control surface anything you want.

Does anybody know the corresponding instructions to do the same with a
Form?

(clearly this is different by setting the form opacity, and allows for
instance to draw sharp
pictures on a transparent surface: opacity would instead be inherited
by images drawn on the form).

-tom

  Reply With Quote
Old 21-05-2006, 08:28 AM   #2
gene kelley
Guest
 
Posts: n/a
Default Re: Transparent Form surface

On 20 May 2006 16:28:36 -0700, tommaso.gastaldi@uniroma1.it wrote:

>I found useful to use transparent controls like:
>
>'----------------------------------------------------------------------------------
>Public Class UserControlTransp
> Inherits System.Windows.Forms.UserControl
>
>#Region " Windows Form Designer generated code "
>...
>#End Region
>
> Protected Overrides ReadOnly Property CreateParams() As
>System.Windows.Forms.CreateParams
> Get
> Dim MyParams As CreateParams = MyBase.CreateParams()
> MyParams.ExStyle = MyParams.ExStyle Or &H20
> Return MyParams
> End Get
> End Property
>
> Protected Overrides Sub OnPaintBackground(ByVal e As
>System.Windows.Forms.PaintEventArgs)
> ' for transparency
> End Sub
>
> Protected Overrides Sub OnPaint(ByVal e As
>System.Windows.Forms.PaintEventArgs)
> ' Any drawing here ...
> ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(10, 10,
>200, 100), Border3DStyle.Etched)
> e.Graphics.FillEllipse(New SolidBrush(Color.FromArgb(100, 120,
>200, 255)), New Rectangle(30, 30, 100, 100))
> End Sub
>
>End Class
>
>'----------------------------------------------------------------------------------
>
>this allows to draw on a trasparent control surface anything you want.
>
>Does anybody know the corresponding instructions to do the same with a
>Form?
>
>(clearly this is different by setting the form opacity, and allows for
>instance to draw sharp
>pictures on a transparent surface: opacity would instead be inherited
>by images drawn on the form).
>
>-tom



See if this is what you are looking for if VB2005:

Set Form's Backcolor and TransparencyKey colors to same color.
Any control with a Backcolor other than the TransparencyKey color, or,
any drawn graphics using non-key colors will be dispalyed on a
transparent form background.

With a borderless form, this is one way to create an irregular shaped
form.

Gene

  Reply With Quote
Old 21-05-2006, 10:34 AM   #3
tommaso.gastaldi@uniroma1.it
Guest
 
Posts: n/a
Default Re: Transparent Form surface

Hi Gene, thank you

I am aware of the method you describe. What I was aiming to find is
something that let me use the form as a purely transparent surface
where to draw on.

Setting the transparency key is something slightly different. It will
also affect the drawing.
And, more importantly, the color removal id done very badly and along
irregular borders one can often see pixels of the masked color.

I was just hoping there is a simple way to have a clean graphics where
one can draw and that, at the same time, can be managed as a form...

-tom

gene kelley ha scritto:

>
> Set Form's Backcolor and TransparencyKey colors to same color.
> Any control with a Backcolor other than the TransparencyKey color, or,
> any drawn graphics using non-key colors will be dispalyed on a
> transparent form background.
>
> With a borderless form, this is one way to create an irregular shaped
> form.
>
> Gene


  Reply With Quote
Old 21-05-2006, 05:45 PM   #4
=?Utf-8?B?S2VuIFR1Y2tlciBbTVZQXQ==?=
Guest
 
Posts: n/a
Default Re: Transparent Form surface

Hi,

Mike Harsh did a msdn tv episode about making non rectangular
forms using regions. Maybe that will help you.

http://msdn.microsoft.com/msdntv/ep...MH/manifest.xml

Ken
---------------------

"tommaso.gastaldi@uniroma1.it" wrote:

> Hi Gene, thank you
>
> I am aware of the method you describe. What I was aiming to find is
> something that let me use the form as a purely transparent surface
> where to draw on.
>
> Setting the transparency key is something slightly different. It will
> also affect the drawing.
> And, more importantly, the color removal id done very badly and along
> irregular borders one can often see pixels of the masked color.
>
> I was just hoping there is a simple way to have a clean graphics where
> one can draw and that, at the same time, can be managed as a form...
>
> -tom
>
> gene kelley ha scritto:
>
> >
> > Set Form's Backcolor and TransparencyKey colors to same color.
> > Any control with a Backcolor other than the TransparencyKey color, or,
> > any drawn graphics using non-key colors will be dispalyed on a
> > transparent form background.
> >
> > With a borderless form, this is one way to create an irregular shaped
> > form.
> >
> > Gene

>
>

  Reply With Quote
Old 21-05-2006, 07:14 PM   #5
tommaso.gastaldi@uniroma1.it
Guest
 
Posts: n/a
Default Re: Transparent Form surface

Thanks Ken, that's a nice video!

I am beginning to think that to achieve this effect it is necessary to
define a "floating transparent control" (i.e. whose parent is actually
the desktop). I think I have read somewhere about that technique,
although I am not sure where...

Ken ha scritto:

> Hi,
>
> Mike Harsh did a msdn tv episode about making non rectangular
> forms using regions. Maybe that will help you.
>
> http://msdn.microsoft.com/msdntv/ep...MH/manifest.xml
>
> Ken
> ---------------------
>
> "tommaso.gastaldi@uniroma1.it" wrote:
>
> > Hi Gene, thank you
> >
> > I am aware of the method you describe. What I was aiming to find is
> > something that let me use the form as a purely transparent surface
> > where to draw on.
> >
> > Setting the transparency key is something slightly different. It will
> > also affect the drawing.
> > And, more importantly, the color removal id done very badly and along
> > irregular borders one can often see pixels of the masked color.
> >
> > I was just hoping there is a simple way to have a clean graphics where
> > one can draw and that, at the same time, can be managed as a form...
> >
> > -tom
> >
> > gene kelley ha scritto:
> >
> > >
> > > Set Form's Backcolor and TransparencyKey colors to same color.
> > > Any control with a Backcolor other than the TransparencyKey color, or,
> > > any drawn graphics using non-key colors will be dispalyed on a
> > > transparent form background.
> > >
> > > With a borderless form, this is one way to create an irregular shaped
> > > form.
> > >
> > > Gene

> >
> >


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off