From 53d51105bee5319a3f9c4453c851d6e154c463dc Mon Sep 17 00:00:00 2001 From: Anton Triest Date: Fri, 27 Mar 2020 12:02:36 +0100 Subject: [PATCH] Fix drawing of non-solid lines with width 0 using wxDC in wxMSW ::ExtCreatePen() doesn't allow the pen width to be 0, unlike ::CreatePen() and failed to create the brush in this case. Use width of 1 to draw e.g. hatched lines of width 0 correctly. See #7097. --- src/msw/pen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp index 6ad3c57b33..44bcc3ebf6 100644 --- a/src/msw/pen.cpp +++ b/src/msw/pen.cpp @@ -356,7 +356,10 @@ bool wxPenRefData::Alloc() dash = NULL; } - m_hPen = ::ExtCreatePen(styleMSW, m_width, &lb, m_nbDash, (LPDWORD)dash); + // Note that width can't be 0 for ExtCreatePen(), unlike for CreatePen(). + int width = m_width == 0 ? 1 : m_width; + + m_hPen = ::ExtCreatePen(styleMSW, width, &lb, m_nbDash, (LPDWORD)dash); delete [] dash; }