-    //       we could solve this by storing the limit we set in wxTextCtrl but
-    //       to save space we prefer to simply test here the actual limit
-    //       value: we consider that SetMaxLength() can only be called for
-    //       values < 32Kb
-    if ( limit < 0x8000 )
-    {
-        // we've got more text than limit set by SetMaxLength()
+    //       Unfortunately there is no EM_GETLIMITTEXTSETBYUSER and so we don't
+    //       know the limit we set (if any). We could solve this by storing the
+    //       limit we set in wxTextCtrl but to save space we prefer to simply
+    //       test here the actual limit value: we consider that SetMaxLength()
+    //       can only be called for small values while EN_MAXTEXT is only sent
+    //       for large values (in practice the default limit seems to be 30000
+    //       but make it smaller just to be on the safe side)
+    *len = ::SendMessage(GetHwnd(), EM_GETLIMITTEXT, 0, 0);
+    return *len < 10001;
+
+}
+
+bool wxTextCtrl::AdjustSpaceLimit()
+{
+    unsigned int limit;
+    if ( HasSpaceLimit(&limit) )