Serialcoder en Français Serialcoder in English
TEL : +33 (0)9 72 13 15 17

Windows Forms FAQ resources

2. Windows Forms Controls

2.8 How do I provide a 2 pixel 3d border in the Non-Client area of my Control derived class?


You can do so as follows by overriding the CreateParams property in your Control. The advantage with this approach is that drawing is handled by the system as soon as you set the flag below.


          protected override CreateParams CreateParams
          {
               get
               {
                    CreateParams cparams;

                    cparams = base.CreateParams;

                    if(this.need3DBorder)
                    {
                         cparams.ExStyle &= ~512;
                         cparams.Style &= ~8388608 /*WS_BORDER*/;
                         cparams.ExStyle = cparams.ExStyle | 512 /*WS_EX_DLGFRAME*/;
                    }
                    return cparams;
               }

          }