Skip to content

simos-sigma/vb.net_winform_dropshadow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

VB.NET WINFORM DROPSHADOW

A VB.NET Winform DropShadow demo by Simonetos The Greek.

The initial idea started from a question at stackoverflow.com titled "Windows 7 style Dropshadow in borderless form" by Corylulu. Then, Wener made a workable class in C# which you can find it here. I managed to translate this class to a workable VB.NET class and also add the Shadow Radius ability. I also made the demo a bit easier to use and a bit more good looking.

SAMPLES


WHAT DROPSHADOW CLASS DO?

By including this class into your VB.NET Winforms...

  1. Basically, you can give shadow to a borderless form.
  2. You can make form's shadow size as big as you want.
  3. You can set shadow's horizontal and vertical position using negative and positive values.
  4. You can make form's shadow looks blurred.
  5. You can change shadow's color and opacity.
  6. And finaly, you can add shadow radius.
  7. You can also add form radius (manualy!!!).

USAGE

Here is an example of how you can use DropShadow class into your form's code.

Public Class Form1

    '((( Declare DropShadow class. )))
    Public _Shadow As Dropshadow
    
    '((( Add the necessary initializations for your form. )))
    Public Sub New()
        InitializeComponent()
        Me.FormBorderStyle = FormBorderStyle.None
        Me.DoubleBuffered = True
    End Sub
    
    '((( And here we go... )))
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not DesignMode Then
            _Shadow = New Dropshadow(Me) With {
                .ShadowH = 0,
                .ShadowV = 0,
                .ShadowBlur = 5,
                .ShadowSpread = 5,
                .Opacity = 128,
                .ShadowColor = Color.FromArgb(CInt(.Opacity), 0, 0, 0),
                .ShadowRadius = 0
            }
            _Shadow.RefreshShadow()
        End If
    End Sub
	
End Class

And how you can add form radius. You should do that manualy.

'((( Replace *** with a number of your choice. )))
Me.Region = Region.FromHrgn(Win32.CreateRoundRectRgn(0, 0, Me.Width + 1, Me.Height + 1, ***, ***))
_Shadow.RefreshShadow()

As you will see in Demo project, you should also manually do _Shadow.RefreshShadow() every time that form changes state or size. For example, when form changes state from FormWindowState.Normal to FormWindowState.Maximized or when you resize the form using a resize handler.

You can find the DropShadow class file here.

About

A VB.NET Winform DropShadow Class.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published