decreased text limit which we consider to be set by user (and not built in the control) to 10001 which is less than default 30000

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-07-29 23:01:56 +00:00
parent f3d0213e5b
commit 4fa8085100
2 changed files with 38 additions and 35 deletions

View File

@@ -201,6 +201,10 @@ protected:
// intercept WM_GETDLGCODE // intercept WM_GETDLGCODE
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// return true if this control has a user-set limit on amount of text (i.e.
// the limit is due to a previous call to SetMaxLength() and not built in)
bool HasSpaceLimit(unsigned int *len) const;
// call this to increase the size limit (will do nothing if the current // call this to increase the size limit (will do nothing if the current
// limit is big enough) // limit is big enough)
// //

View File

@@ -1561,11 +1561,22 @@ void wxTextCtrl::SetMaxLength(unsigned long len)
{ {
#if wxUSE_RICHEDIT #if wxUSE_RICHEDIT
if ( IsRich() ) if ( IsRich() )
::SendMessage(GetHwnd(), EM_EXLIMITTEXT, 0, (LPARAM) (DWORD) len); {
::SendMessage(GetHwnd(), EM_EXLIMITTEXT, 0, len ? len : 0x7fffffff);
}
else else
#endif #endif // wxUSE_RICHEDIT
{
if ( len >= 0xffff )
{
// this will set it to a platform-dependent maximum (much more
// than 64Kb under NT)
len = 0;
}
::SendMessage(GetHwnd(), EM_LIMITTEXT, len, 0); ::SendMessage(GetHwnd(), EM_LIMITTEXT, len, 0);
} }
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Undo/redo // Undo/redo
@@ -1894,48 +1905,36 @@ WXHBRUSH wxTextCtrl::MSWControlColor(WXHDC hDC, WXHWND hWnd)
return wxTextCtrlBase::MSWControlColor(hDC, hWnd); return wxTextCtrlBase::MSWControlColor(hDC, hWnd);
} }
bool wxTextCtrl::AdjustSpaceLimit() bool wxTextCtrl::HasSpaceLimit(unsigned int *len) const
{ {
unsigned int limit = ::SendMessage(GetHwnd(), EM_GETLIMITTEXT, 0, 0);
// HACK: we try to automatically extend the limit for the amount of text // HACK: we try to automatically extend the limit for the amount of text
// to allow (interactively) entering more than 64Kb of text under // to allow (interactively) entering more than 64Kb of text under
// Win9x but we shouldn't reset the text limit which was previously // Win9x but we shouldn't reset the text limit which was previously
// set explicitly with SetMaxLength() // set explicitly with SetMaxLength()
// //
// we could solve this by storing the limit we set in wxTextCtrl but // Unfortunately there is no EM_GETLIMITTEXTSETBYUSER and so we don't
// to save space we prefer to simply test here the actual limit // know the limit we set (if any). We could solve this by storing the
// value: we consider that SetMaxLength() can only be called for // limit we set in wxTextCtrl but to save space we prefer to simply
// values < 32Kb // test here the actual limit value: we consider that SetMaxLength()
if ( limit < 0x8000 ) // 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
// we've got more text than limit set by SetMaxLength() // but make it smaller just to be on the safe side)
return false; *len = ::SendMessage(GetHwnd(), EM_GETLIMITTEXT, 0, 0);
return *len < 10001;
} }
bool wxTextCtrl::AdjustSpaceLimit()
{
unsigned int limit;
if ( HasSpaceLimit(&limit) )
return false;
unsigned int len = ::GetWindowTextLength(GetHwnd()); unsigned int len = ::GetWindowTextLength(GetHwnd());
if ( len >= limit ) if ( len >= limit )
{ {
limit = len + 0x8000; // 32Kb // increment in 32Kb chunks
SetMaxLength(len + 0x8000);
#if wxUSE_RICHEDIT
if ( IsRich() )
{
// as a nice side effect, this also allows passing limit > 64Kb
::SendMessage(GetHwnd(), EM_EXLIMITTEXT, 0, limit);
}
else
#endif // wxUSE_RICHEDIT
{
if ( limit > 0xffff )
{
// this will set it to a platform-dependent maximum (much more
// than 64Kb under NT)
limit = 0;
}
::SendMessage(GetHwnd(), EM_LIMITTEXT, limit, 0);
}
} }
// we changed the limit // we changed the limit