private unsafe void CreatePen() { if (_width > 1) { // Geometric pen. // From MSDN: if width > 1, the style must be PS_NULL, PS_SOLID, or PS_INSIDEFRAME. _style |= Gdi32.PS.GEOMETRIC | Gdi32.PS.SOLID; } if (_wndBrush == null) { _nativeHandle = Gdi32.CreatePen(_style, _width, ColorTranslator.ToWin32(_color)); } else { var lb = new Gdi32.LOGBRUSH { lbColor = ColorTranslator.ToWin32(_wndBrush.Color), lbStyle = Gdi32.BS.SOLID, lbHatch = IntPtr.Zero }; // Note: We currently don't support custom styles, that's why 0 and null for last two params. _nativeHandle = Gdi32.ExtCreatePen(_style, _width, ref lb, 0, null); } }