+}
+
+#endif // wxHAVE_EXT_CREATE_PEN
+
+bool wxPenRefData::Alloc()
+{
+ if ( m_hPen )
+ return false;
+
+ if ( m_style == wxTRANSPARENT )
+ {
+ m_hPen = (HPEN)::GetStockObject(NULL_PEN);
+ return true;
+ }
+
+ const COLORREF col = m_colour.GetPixel();
+
+#ifdef wxHAVE_EXT_CREATE_PEN
+ // Only NT can display dashed or dotted lines with width > 1
+ static const int os = wxGetOsVersion();
+ if ( os != wxOS_WINDOWS_NT &&
+ (m_style == wxDOT ||
+ m_style == wxLONG_DASH ||
+ m_style == wxSHORT_DASH ||
+ m_style == wxDOT_DASH ||
+ m_style == wxUSER_DASH) &&
+ m_width > 1 )
+ {
+ m_width = 1;
+ }
+
+ // check if it's a standard kind of pen which can be created with just
+ // CreatePen()
+ if ( m_join == wxJOIN_ROUND &&
+ m_cap == wxCAP_ROUND &&
+ m_style != wxUSER_DASH &&
+ m_style != wxSTIPPLE &&
+ (m_width <= 1 || m_style == wxSOLID) )
+#endif // !wxHAVE_EXT_CREATE_PEN
+ {
+ m_hPen = ::CreatePen(ConvertPenStyle(m_style), m_width, col);
+ }
+#ifdef wxHAVE_EXT_CREATE_PEN
+ else // need to use ExtCreatePen()
+ {
+ DWORD styleMSW = PS_GEOMETRIC |
+ ConvertPenStyle(m_style) |
+ ConvertJoinStyle(m_join) |
+ ConvertCapStyle(m_cap);
+
+ LOGBRUSH lb;
+ switch( m_style )
+ {
+ case wxSTIPPLE:
+ lb.lbStyle = BS_PATTERN;
+ lb.lbHatch = (LONG)m_stipple.GetHBITMAP();
+ break;
+
+ case wxBDIAGONAL_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_BDIAGONAL;
+ break;
+
+ case wxCROSSDIAG_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_DIAGCROSS;
+ break;
+
+ case wxFDIAGONAL_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_FDIAGONAL;
+ break;
+
+ case wxCROSS_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_CROSS;
+ break;
+
+ case wxHORIZONTAL_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_HORIZONTAL;
+ break;
+
+ case wxVERTICAL_HATCH:
+ lb.lbStyle = BS_HATCHED;
+ lb.lbHatch = HS_VERTICAL;
+ break;
+
+ default:
+ lb.lbStyle = BS_SOLID;
+#ifdef __WXDEBUG__
+ // this should be unnecessary (it's unused) but suppresses the
+ // Purify messages about uninitialized memory read
+ lb.lbHatch = 0;