FWIW, the code makes sure the appropriate window is selected.
Code: Select all
void MyFrame::DoFind( const wxString arc_ws2Find, wxTextCtrl* a_pTextCtrl )
{
long lStart;
long lFoundPos;
long Last;
bool bDown = true;
bool bMatchCase = false;
a_pTextCtrl->ShowPosition( 0 );
wxString wsContent = a_pTextCtrl->GetValue();
if ( !bMatchCase )
wsContent = wsContent.MakeLower();
if (bMatchCase )
lFoundPos = (bDown) ? wsContent.find(arc_ws2Find) : wsContent.rfind(arc_ws2Find);
else
lFoundPos = (bDown) ? wsContent.Lower().find(arc_ws2Find) : wsContent.Lower().rfind(arc_ws2Find);
if ( lFoundPos == wxNOT_FOUND )
return;
long lStartPos = (bDown) ? a_pTextCtrl->GetInsertionPoint() + lFoundPos : lFoundPos;
long lEndPos = lStartPos + arc_ws2Find.length();
a_pTextCtrl->SetSelection(lFoundPos, lFoundPos + arc_ws2Find.length());
a_pTextCtrl->ShowPosition( lFoundPos + arc_ws2Find.length() ); // <<<<<everything works up to here
// none of these show the selection
// a_pTextCtrl->Update();//SetFocus();//Layout();//Refresh();
// a_pTextCtrl->SendSizeEventToParent();
// a_pTextCtrl->LineDown();
a_pTextCtrl->Refresh();
::wxYield();
// a_pTextCtrl->FitInside();
// a_pTextCtrl->ShowPosition( lFoundPos + arc_ws2Find.length() );
}
The big question: how can I make the selection appear without the extra switching. In fact, the only way I noticed that the selection had been done, was when I by chance ended up switching between the 2 windows