Page 1 of 1

Form DropShadow

Posted: Thu Apr 22, 2010 8:30 pm
by mikethedj4
I know this is possible, but I was wondering, how do you add a dropshadow to a form???

Re: Form DropShadow

Posted: Thu Apr 22, 2010 9:37 pm
by CodenStuff
Hello,

I think to do this it would be better to have a second form open behind your main form and set it slightly off-center so it looks like a shadow and have it move when you move the main form.

But you can try this code which works on XP but not guaranteed to work on Vista/7. Just add it at the very top of your code after "Public Class From..":
Code: Select all
Private Const CS_DROPSHADOW As Integer = 131072
    Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
        Get
            Dim Shadow As CreateParams = MyBase.CreateParams
            Shadow.ClassStyle = Shadow.ClassStyle Or CS_DROPSHADOW
            Return Shadow
        End Get
    End Property

Re: Form DropShadow

Posted: Thu Apr 22, 2010 10:30 pm
by mikethedj4
I tried that before, and it didn't seem to work with my app, or even a new app with nothing on it, but a button with a messagebox.

Re: Form DropShadow

Posted: Thu Apr 22, 2010 11:12 pm
by CodenStuff
Hello,

Do you have the shadow effects switched on in your display settings?

Right-click on desktop > Properties > Appearance > Effects ..then click "Show shadows under menus"

If that option isnt selected then it wont work.

Re: Form DropShadow

Posted: Fri Apr 23, 2010 1:26 am
by mikethedj4
That was why it didn't work lol. At least I learned another new thing, which makes this all worth while.