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

Platform: WinForms| Category: Controls

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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.