#if wxUSE_RICHEDIT
if ( m_isRich )
{
- int len = GetWindowTextLength(GetHwnd()) + 1;
-
wxString str;
- wxChar *p = str.GetWriteBuf(len);
- TEXTRANGE textRange;
- textRange.chrg.cpMin = 0;
- textRange.chrg.cpMax = -1;
- textRange.lpstrText = p;
+ int len = GetWindowTextLength(GetHwnd());
+ if ( len )
+ {
+ // alloc one extra WORD as needed by the control
+ wxChar *p = str.GetWriteBuf(++len);
- (void)SendMessage(GetHwnd(), EM_GETTEXTRANGE, 0, (LPARAM)&textRange);
+ TEXTRANGE textRange;
+ textRange.chrg.cpMin = 0;
+ textRange.chrg.cpMax = -1;
+ textRange.lpstrText = p;
- // believe it or not, but EM_GETTEXTRANGE uses just CR ('\r') for the
- // newlines which is neither Unix nor Windows style (Win95 with
- // riched20.dll shows this behaviour) - convert it to something
- // reasonable
- for ( ; *p; p++ )
- {
- if ( *p == _T('\r') )
- *p = _T('\n');
- }
+ (void)SendMessage(GetHwnd(), EM_GETTEXTRANGE, 0, (LPARAM)&textRange);
- str.UngetWriteBuf();
+ // believe it or not, but EM_GETTEXTRANGE uses just CR ('\r') for
+ // the newlines which is neither Unix nor Windows style (Win95 with
+ // riched20.dll shows this behaviour) - convert it to something
+ // reasonable
+ for ( ; *p; p++ )
+ {
+ if ( *p == _T('\r') )
+ *p = _T('\n');
+ }
+
+ str.UngetWriteBuf();
+ }
+ //else: no text at all, leave the string empty
return str;
}
// Can copy if there's a selection
long from, to;
GetSelection(& from, & to);
- return (from != to);
+ return (from != to) ;
}
bool wxTextCtrl::CanCut() const
// Can cut if there's a selection
long from, to;
GetSelection(& from, & to);
- return (from != to);
+ return (from != to) && (IsEditable());
}
bool wxTextCtrl::CanPaste() const
wxString str;
wxChar *buf = str.GetWriteBuf(len);
- *(WORD *)buf = len;
+ *(WORD *)buf = (WORD)len;
len = (size_t)::SendMessage(GetHwnd(), EM_GETLINE, lineNo, (LPARAM)buf);
buf[len] = 0;
return TRUE;
}
-WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
- WXUINT message,
- WXWPARAM wParam,
- WXLPARAM lParam)
+WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
+ WXUINT WXUNUSED(message),
+ WXWPARAM WXUNUSED(wParam),
+ WXLPARAM WXUNUSED(lParam))
{
#if wxUSE_CTL3D
if ( m_useCtl3D )
int hText = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
if ( m_windowStyle & wxTE_MULTILINE )
{
- hText *= wxMin(GetNumberOfLines(), 5);
+ hText *= wxMax(GetNumberOfLines(), 5);
}
//else: for single line control everything is ok