Adding Drop Shadow on a border-less form.

nssltd 1 Tallied Votes 618 Views Share

Hey,

The reason i am posting this 'snippet' is because a while back i encountered
such a problem and i asked a question but never really received an answer. Basically
i stumbled upon this snippet by luck when just browsing the web. I have searched the
forums but found nothing of a similar nature to what i was posting.

Basically you have to put that snippet in the form class.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NISOFENT
{
    public partial class Form1 : Form
    { private const int CS_DROPSHADOW = 0x20000;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ClassStyle |= CS_DROPSHADOW;
                return cp;
            }
        }
        public Form1()
        {
            InitializeComponent();
        }
    }

}

If i wasn't clear above all this does is put a small drop shadow on the right hand
and bottom side of the BORDERLESS Form. making the form borderless can be achieved
by going into the properties of your form and setting the 'Form Border Style'
setting to none.

If i have left something out or you have any question's feel free to ask

I hope this helped somebody out.

NSSLTD

P.s I hope i wrote this snippet correctly because this my first snippet post :)

WASDted commented: thanks for the contribution +6
private const int CS_DROPSHADOW = 0x20000;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ClassStyle |= CS_DROPSHADOW;
                return cp;
            }
        }