Optimize wxTextCtrl::GetLastPosition()
It's better to call one API instead of four.
This commit is contained in:
@@ -1334,12 +1334,19 @@ wxTextPos wxTextCtrl::GetLastPosition() const
|
|||||||
{
|
{
|
||||||
if ( IsMultiLine() )
|
if ( IsMultiLine() )
|
||||||
{
|
{
|
||||||
int numLines = GetNumberOfLines();
|
#if wxUSE_RICHEDIT
|
||||||
long posStartLastLine = XYToPosition(0, numLines - 1);
|
if ( IsRich() )
|
||||||
|
{
|
||||||
long lenLastLine = GetLengthOfLineContainingPos(posStartLastLine);
|
GETTEXTLENGTHEX gtl;
|
||||||
|
gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
|
||||||
return posStartLastLine + lenLastLine;
|
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();
|
return wxTextEntry::GetLastPosition();
|
||||||
|
Reference in New Issue
Block a user