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;
}
}
Share with