Optimize wxTextCtrl::GetLastPosition()
It's better to call one API instead of four.
This commit is contained in:
parent
4fc8753285
commit
c51dd81db6
@ -1334,12 +1334,19 @@ wxTextPos wxTextCtrl::GetLastPosition() const
|
||||
{
|
||||
if ( IsMultiLine() )
|
||||
{
|
||||
int numLines = GetNumberOfLines();
|
||||
long posStartLastLine = XYToPosition(0, numLines - 1);
|
||||
|
||||
long lenLastLine = GetLengthOfLineContainingPos(posStartLastLine);
|
||||
|
||||
return posStartLastLine + lenLastLine;
|
||||
#if wxUSE_RICHEDIT
|
||||
if ( IsRich() )
|
||||
{
|
||||
GETTEXTLENGTHEX gtl;
|
||||
gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
|
||||
gtl.codepage = GetRichVersion() > 1 ? 1200 : CP_ACP;
|
||||
return ::SendMessage(GetHwnd(), EM_GETTEXTLENGTHEX, (WPARAM)>l, 0);
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_RICHEDIT
|
||||
{
|
||||
return ::GetWindowTextLength(GetHwnd());
|
||||
}
|
||||
}
|
||||
|
||||
return wxTextEntry::GetLastPosition();
|
||||
|
Loading…
Reference in New Issue
Block a user