From bf9b6266faaa6534b75e5282aab58f1476eecbaa Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 2 Aug 2001 19:02:17 +0000
Subject: [PATCH] applied patch 446014 (misc mingw fixes from Mattia)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11264 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 include/wx/defs.h        |  6 ++++++
 include/wx/listctrl.h    |  2 ++
 include/wx/msw/gccpriv.h | 10 +++++-----
 src/generic/listctrl.cpp |  1 +
 src/msw/dialup.cpp       |  8 ++++++++
 src/msw/listctrl.cpp     | 11 ++++++-----
 src/msw/tbar95.cpp       |  4 ++--
 src/msw/treectrl.cpp     |  2 +-
 8 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/include/wx/defs.h b/include/wx/defs.h
index 19cefa67f6..8cb02a12d8 100644
--- a/include/wx/defs.h
+++ b/include/wx/defs.h
@@ -37,6 +37,12 @@
     #endif
 #endif // Win32
 
+#if defined(__WXMSW__) || defined(__WIN32__)
+    #if !defined(__WINDOWS__)
+        #define __WINDOWS__
+    #endif
+#endif
+
 #ifdef __WXWINE__
     #ifndef __WIN32__
         #define __WIN32__
diff --git a/include/wx/listctrl.h b/include/wx/listctrl.h
index f8f79a1e4c..8526b2ef27 100644
--- a/include/wx/listctrl.h
+++ b/include/wx/listctrl.h
@@ -331,6 +331,8 @@ public:
     // return TRUE if the item is selected
     bool IsSelected(long index)
         { return GetItemState(index, wxLIST_STATE_SELECTED) != 0; }
+private:
+    DECLARE_DYNAMIC_CLASS(wxListView)
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/wx/msw/gccpriv.h b/include/wx/msw/gccpriv.h
index 1776267b2b..c0e84b250b 100644
--- a/include/wx/msw/gccpriv.h
+++ b/include/wx/msw/gccpriv.h
@@ -3,11 +3,11 @@
 #ifndef _WX_MSW_GCCPRIV_H_
 #define _WX_MSW_GCCPRIV_H_
 
-#if defined( __MINGW32__ )
-    //#include <_mingw.h>
-    #if __MINGW32_MAJOR_VERSION >= 1
-        #ifndef HAVE_W32API_H
-        #define HAVE_W32API_H
+#if defined( __MINGW32__ ) && !defined( HAVE_W32API_H )
+    #if ( __GNUC__ > 2 ) || ( ( __GNUC__ == 2 ) && ( __GNUC_MINOR__ >= 95 ) )
+        #include <_mingw.h>
+        #if __MINGW32_MAJOR_VERSION >= 1
+            #define HAVE_W32API_H
         #endif
     #endif
 #endif
diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp
index 85d1144fdc..93b43f1529 100644
--- a/src/generic/listctrl.cpp
+++ b/src/generic/listctrl.cpp
@@ -4317,6 +4317,7 @@ void wxListEvent::CopyObject(wxObject& object_dest) const
 // -------------------------------------------------------------------------------------
 
 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
 
 BEGIN_EVENT_TABLE(wxListCtrl,wxControl)
   EVT_SIZE(wxListCtrl::OnSize)
diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp
index 5d94d8d8df..e7a00a506b 100644
--- a/src/msw/dialup.cpp
+++ b/src/msw/dialup.cpp
@@ -864,9 +864,17 @@ bool wxDialUpManagerMSW::Dial(const wxString& nameOfISP,
 
     if ( dwRet != 0 )
     {
+#if wxUSE_UNICODE
+        // can't pass a wxWCharBuffer through ( ... )
+        wxLogError(_("Failed to %s dialup connection: %s").data(),
+                   async ? _("initiate").data() : _("establish").data(),
+                   GetErrorString(dwRet).c_str());
+#else
+        // can't pass a wxWCharBuffer through ( ... )
         wxLogError(_("Failed to %s dialup connection: %s"),
                    wxString(async ? _("initiate") : _("establish")).c_str(),
                    GetErrorString(dwRet).c_str());
+#endif
 
         // we should still call RasHangUp() if we got a non 0 connection
         if ( ms_hRasConnection )
diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp
index c974aaf47f..63eb8ffba0 100644
--- a/src/msw/listctrl.cpp
+++ b/src/msw/listctrl.cpp
@@ -123,6 +123,7 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
 
 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
 IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
 
 BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
@@ -480,20 +481,19 @@ long wxListCtrl::ConvertToMSWStyle(long& oldStyle, long style) const
         wstyle |= LVS_SORTDESCENDING;
     }
 
+#if !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) )
     if ( style & wxLC_VIRTUAL )
     {
         int ver = wxTheApp->GetComCtl32Version();
         if ( ver < 470 )
         {
-            wxLogWarning(_("Please install a newer version of comctl32.dll\n"
-                           "(at least version 4.70 is required but you have "
-                           "%d.%02d)\n"
-                           "or this program won't operate correctly."),
+            wxLogWarning(_("Please install a newer version of comctl32.dll\n(at least version 4.70 is required but you have %d.%02d)\nor this program won't operate correctly."),
                         ver / 100, ver % 100);
         }
 
         wstyle |= LVS_OWNERDATA;
     }
+#endif
 
     return wstyle;
 }
@@ -1625,7 +1625,8 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             break;
 #endif // 0
 
-#if defined(_WIN32_IE) && _WIN32_IE >= 0x300
+#if defined(_WIN32_IE) && _WIN32_IE >= 0x300 \
+    && !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) )
         case NM_CUSTOMDRAW:
             *result = OnCustomDraw(lParam);
 
diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp
index 7d209cc801..f1ed7ca012 100644
--- a/src/msw/tbar95.cpp
+++ b/src/msw/tbar95.cpp
@@ -1058,7 +1058,7 @@ void wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height)
     //  ColorMap[4].from = sm_stdColours[4]; ColorMap[4].to = COLOR_HIGHLIGHT;  // blue         (0, 0, 255)
     ColorMap[4].from = sm_stdColours[5]; ColorMap[4].to = COLOR_WINDOW;       // magenta      (255, 0, 255)
 
-    for ( int n = 0; n < WXSIZEOF(ColorMap); n++)
+    for ( size_t n = 0; n < WXSIZEOF(ColorMap); n++)
     {
         ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
     }
@@ -1076,7 +1076,7 @@ void wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height)
             {
                 COLORREF pixel = ::GetPixel(hdcMem, i, j);
 
-                for ( int k = 0; k < WXSIZEOF(ColorMap); k++ )
+                for ( size_t k = 0; k < WXSIZEOF(ColorMap); k++ )
                 {
                     int distance = abs( GetRValue( pixel ) - GetRValue( ColorMap[k].from )) ;
                     distance = max( distance , abs(GetGValue(pixel ) - GetGValue( ColorMap[k].from ))) ;
diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp
index 5d48e4c938..5e20b78bb5 100644
--- a/src/msw/treectrl.cpp
+++ b/src/msw/treectrl.cpp
@@ -2141,7 +2141,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             }
             break;
 
-#if defined(_WIN32_IE) && _WIN32_IE >= 0x300 && !wxUSE_COMCTL32_SAFELY && !defined(__GNUWIN32__)
+#if defined(_WIN32_IE) && _WIN32_IE >= 0x300 && !wxUSE_COMCTL32_SAFELY && !( defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 1, 0 ) )
         case NM_CUSTOMDRAW:
             {
                 LPNMTVCUSTOMDRAW lptvcd = (LPNMTVCUSTOMDRAW)lParam;
-- 
2.47.2