SIL.FieldWorks.Common.Widgets.VSTabControl.InitializeDrawMode C# (CSharp) Method

InitializeDrawMode() private method

Turns custom drawing on/off and sets native font for the control (it's required for tabs to adjust their size correctly). If one doesn't install native font manually then Windows will install ugly system font for the control.
private InitializeDrawMode ( ) : void
return void
		private void InitializeDrawMode()
		{
			this.fCustomDraw = Application.RenderWithVisualStyles && TabRenderer.IsSupported;
			this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
				ControlStyles.OptimizedDoubleBuffer, this.fCustomDraw);
			this.UpdateStyles();
			if (this.fCustomDraw) //custom drawing will be used
			{
				if (this.fSysFont == IntPtr.Zero) this.fSysFont = this.Font.ToHfont();
				NativeMethods.SendMessage(this.Handle, NativeMethods.WM_SETFONT, this.fSysFont, (IntPtr)1);
			}
			else //default drawing will be used
			{
				/* Note that in the SendMessage call below we do not delete HFONT passed to control. If we do
				 * so we can see ugly system font. I think in this case the control deletes this font by itself
				 * when disposing or finalizing.*/
				NativeMethods.SendMessage(this.Handle, NativeMethods.WM_SETFONT, this.Font.ToHfont(), (IntPtr)1);
				//but we need to delete the font(if any) created when being in custom drawing mode
				if (this.fSysFont != IntPtr.Zero)
				{
					NativeMethods.DeleteObject(this.fSysFont);
					this.fSysFont = IntPtr.Zero;
				}
			}
		}