]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/utils.cpp
no changes, just the file I forgot to commit...
[wxWidgets.git] / src / msw / utils.cpp
index 453880612db140757b89f1301e823640b1d5f052..34b1ee859ae625abbfb6a197eb91824b7e1e6556 100644 (file)
@@ -61,9 +61,10 @@ extern "C" {
     #endif
 #endif  //GNUWIN32
 
-#if defined(__GNUWIN32__) && !defined(__TWIN32__)
+#if defined(__CYGWIN__) && !defined(__TWIN32__)
     #include <sys/unistd.h>
     #include <sys/stat.h>
+    #include <sys/cygwin.h> // for cygwin_conv_to_full_win32_path()
 #endif  //GNUWIN32
 
 #ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
@@ -372,6 +373,13 @@ const wxChar* wxGetHomeDir(wxString *pstr)
     // add a trailing slash if needed
     if ( strDir.Last() != wxT('/') )
       strDir << wxT('/');
+
+    #ifdef __CYGWIN__
+      // Cygwin returns unix type path but that does not work well
+      static wxChar windowsPath[MAX_PATH];
+      cygwin_conv_to_full_win32_path(strDir, windowsPath);
+      strDir = windowsPath;
+    #endif
   #else   // Windows
     #ifdef  __WIN32__
       const wxChar *szHome = wxGetenv(wxT("HOMEDRIVE"));
@@ -454,13 +462,15 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
     if ( path.empty() )
         return FALSE;
 
-#if defined(__WIN32__) && !defined(__GNUWIN32__)
+// old w32api don't have ULARGE_INTEGER
+#if defined(__WIN32__) && \
+    (!defined(__GNUWIN32__) || wxCHECK_W32API_VERSION( 0, 3 ))
     // GetDiskFreeSpaceEx() is not available under original Win95, check for
     // it
-    typedef BOOL (*GetDiskFreeSpaceEx_t)(LPCTSTR,
-                                         PULARGE_INTEGER,
-                                         PULARGE_INTEGER,
-                                         PULARGE_INTEGER);
+    typedef BOOL (WINAPI *GetDiskFreeSpaceEx_t)(LPCTSTR,
+                                                PULARGE_INTEGER,
+                                                PULARGE_INTEGER,
+                                                PULARGE_INTEGER);
 
     GetDiskFreeSpaceEx_t
         pGetDiskFreeSpaceEx = (GetDiskFreeSpaceEx_t)::GetProcAddress
@@ -1379,59 +1389,47 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
 wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
 {
     wxString str;
-    int len = GetWindowTextLength((HWND)hWnd) + 1;
-    GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
-    str.UngetWriteBuf();
+
+    if ( hWnd )
+    {
+        int len = GetWindowTextLength((HWND)hWnd) + 1;
+        ::GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
+        str.UngetWriteBuf();
+    }
 
     return str;
 }
 
 wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
 {
-#ifdef __WXMICROWIN__
-    // MICROWIN_TODO
-    return wxEmptyString;
-#else
     wxString str;
 
-    int len = 256; // some starting value
-
-    for ( ;; )
+    // MICROWIN_TODO
+#ifndef __WXMICROWIN__
+    if ( hWnd )
     {
-        // as we've #undefined GetClassName we must now manually choose the
-        // right function to call
-        int count =
-
-        #ifndef __WIN32__
-            GetClassName
-        #else // Win32
-            #ifdef UNICODE
-                GetClassNameW
-            #else // !Unicode
-                #ifdef __TWIN32__
-                    GetClassName
-                #else // !Twin32
-                    GetClassNameA
-                #endif // Twin32/!Twin32
-            #endif // Unicode/ANSI
-        #endif // Win16/32
-                                    ((HWND)hWnd, str.GetWriteBuf(len), len);
+        int len = 256; // some starting value
 
-        str.UngetWriteBuf();
-        if ( count == len )
-        {
-            // the class name might have been truncated, retry with larger
-            // buffer
-            len *= 2;
-        }
-        else
+        for ( ;; )
         {
-            break;
+            int count = ::GetClassName((HWND)hWnd, str.GetWriteBuf(len), len);
+
+            str.UngetWriteBuf();
+            if ( count == len )
+            {
+                // the class name might have been truncated, retry with larger
+                // buffer
+                len *= 2;
+            }
+            else
+            {
+                break;
+            }
         }
     }
+#endif // !__WXMICROWIN__
 
     return str;
-#endif
 }
 
 WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd)