From e7c9708b4fa7d4bd3ed2be3fb5d8821f3cd5669e Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 4 May 2015 03:42:16 +0800 Subject: [PATCH] fix some MinGW compiling errors --- source/datetime.cpp | 4 ++-- source/detail/win32/platform_spec.cpp | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/source/datetime.cpp b/source/datetime.cpp index c326d19e..4682c32c 100644 --- a/source/datetime.cpp +++ b/source/datetime.cpp @@ -19,7 +19,7 @@ namespace { void localtime(struct tm& tm) { -#if defined(NANA_WINDOWS) +#if defined(NANA_WINDOWS) && !defined(NANA_MINGW) time_t t; ::time(&t); if(localtime_s(&tm, &t) != 0) @@ -274,7 +274,7 @@ namespace nana { value_.hour = t.tm_hour; value_.minute = t.tm_min; - value_.second = t.tm_sec; + value_.second = t.tm_sec; } time::time(unsigned hour, unsigned minute, unsigned second) diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index 3f8d8bf9..18b85f01 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -16,7 +16,10 @@ #include PLATFORM_SPEC_HPP #include #include + +#if defined(_MSC_VER) #include +#endif // _MSVC namespace nana { @@ -90,7 +93,7 @@ namespace detail if (brush.color != color_) brush.set(context, brush.style, color_); } - + void drawable_impl_type::pen_spec::set(HDC context, int style, int width, unsigned clr) { if (this->color != clr || this->width != width || this->style != style) @@ -185,10 +188,16 @@ namespace detail NONCLIENTMETRICS metrics = {}; metrics.cbSize = sizeof metrics; #if(WINVER >= 0x0600) - if(!IsWindowsVistaOrGreater()) - { +#if defined(NANA_MINGW) + OSVERSIONINFO osvi = {}; + osvi.dwOSVersionInfoSize = sizeof(osvi); + ::GetVersionEx(&osvi); + if (osvi.dwMajorVersion < 6) metrics.cbSize -= sizeof(metrics.iPaddedBorderWidth); - } +#else + if(!IsWindowsVistaOrGreater()) + metrics.cbSize -= sizeof(metrics.iPaddedBorderWidth); +#endif #endif ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof metrics, &metrics, 0); def_font_ptr_ = make_native_font(metrics.lfMessageFont.lfFaceName, font_size_to_height(9), 400, false, false, false);