]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/utilsgui.cpp
Clipboard usage fixes inspired by Tinderbox logs.
[wxWidgets.git] / src / os2 / utilsgui.cpp
index fd710bbc2020136929e43efe0bef30c712d87459..8ccbed4f91bfce2e5706c45ac0d526c927598f6d 100644 (file)
@@ -515,10 +515,12 @@ wxString WXDLLEXPORT wxGetWindowText(
 )
 {
     wxString                        vStr;
-    long                            lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1;
 
-    ::WinQueryWindowText((HWND)hWnd, lLen, vStr.GetWriteBuf((int)lLen));
-    vStr.UngetWriteBuf();
+    if ( hWnd )
+    {
+       long                lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1;
+       ::WinQueryWindowText((HWND)hWnd, lLen, (PSZ)(wxChar*)wxStringBuffer(vStr, lLen));
+    }
 
     return vStr;
 }
@@ -528,22 +530,24 @@ wxString WXDLLEXPORT wxGetWindowClass(
 )
 {
     wxString                        vStr;
-    int                             nLen = 256; // some starting value
-
-    for ( ;; )
+    if ( hWnd )
     {
-        int                         nCount = ::WinQueryClassName((HWND)hWnd, nLen, vStr.GetWriteBuf(nLen));
-
-        vStr.UngetWriteBuf();
-        if (nCount == nLen )
-        {
-            // the class name might have been truncated, retry with larger
-            // buffer
-            nLen *= 2;
-        }
-        else
-        {
-            break;
+        int                         nLen = 256; // some starting value
+
+       for ( ;; )
+       {
+           int                     nCount = ::WinQueryClassName((HWND)hWnd, nLen, (PSZ)(wxChar*)wxStringBuffer(vStr, nLen));
+
+           if (nCount == nLen )
+           {
+               // the class name might have been truncated, retry with larger
+               // buffer
+               nLen *= 2;
+           }
+           else
+           {
+               break;
+           }
         }
     }
     return vStr;