Programmieren - alles kontrollieren 4.939 Themen, 20.671 Beiträge

Power++ - Suchen/Ersetzen

Tweety4 / 4 Antworten / Flachansicht Nickles

Hallo
brauche schon wieder Hilfe. Habe mit nachfolgendem Programmteil ein Problem. Es läuft nicht so wie es soll. Beim Suchen mit der Option "Groß-/Kleinschreibung beachten" reagiert es nicht und beim Aktivieren von "nach oben" soll es von einer beliebigen Textposition aus nach oben suchen. Beim Erreichen soll es wieder von hinten anfangen zu suchen.
Was muss noch rein, damit das Programm dies alles bewerkstelligt?
Kann mir hier jemand helfen?

WBool Form1::Suchen_Ersetzen_Dialog_1_FindReplace(
WObject * source,
WFindReplaceEventData * event )
{
WLong position;
WString suchtext;
WRange zeichen_index;
WLong text_laenge;
WBool ganzwort, grossklein;

ganzwort = event->wholeWord;
grossklein = event->matchCase;

if (event->findNext)
{
suchtext = Suchen_Ersetzen_Dialog_1->GetFindText();
if (event->searchDown)
{
position = Richtextfeld_1->FindText( suchtext, FALSE, ganzwort, grossklein, beginAt );
if (position {
position = Richtextfeld_1->FindText(suchtext);
}
text_laenge = suchtext.GetLength();
zeichen_index.start = position;
zeichen_index.end = position + text_laenge;
beginAt = zeichen_index.end;

Richtextfeld_1->SetFocus( );
Richtextfeld_1->SetEditSelection( zeichen_index );
}
else
{}
if (event->searchDown)
{
position = Richtextfeld_1->FindText (suchtext, TRUE, ganzwort, grossklein, position);
if (position > 0)
{
position = Richtextfeld_1->FindText (suchtext);
}
text_laenge = suchtext.GetLength();
zeichen_index.start = position;
zeichen_index.end = position - text_laenge;
beginAt = zeichen_index.end;

Richtextfeld_1->SetFocus( );
Richtextfeld_1->SetEditSelection( zeichen_index );
}
else
{}
}
return FALSE;
}

bei Antwort benachrichtigen
Tweety4 Andreas42 „Hi! Ich denke das wichtigste wird die Methode findtext sein. Kannst du hierzu...“
Optionen

Hi Andreas,
danke, dass du wieder so schnell geantwortet hast. Unten stehend schicke ich dir den Onlinetext. Leider gibt es da nämlich keine seachUp-Funktion. Deshalb dachte ich mit TRUE (Gegenteil von FALSE) zu arbeiten. Aber schau dir erstmal die Hilfe zu FindNext an. Vielleicht ergibt sich daraus ja die Lösung, die ich mal wieder nicht sehe.

Hilfe:
When you display a find dialog box with PromptForFind, the function simply displays the dialog box and returns; it does not wait for the user to enter information into the dialog box. The program does not take action on a user’s search request until the user clicks Find Next in the find dialog box. Similarly, when you display a replace dialog box with PromptForReplace, the function returns immediately and the program does not take action until the user clicks an appropriate button in the dialog box.

When the user clicks a Find or Replace button in a find or replace dialog, it generates a FindReplace event on the dialog box. You can create a FindReplace event handler for the dialog box in the usual way: use the right mouse button to click on the dialog box, click Events, then click FindReplace.
When the FindReplace event handler is invoked, the event argument refers to a WFindReplaceEventData object. This type is derived from the WEventData type. WFindReplaceEventData includes all the data members of WEventData, as well as the following public data members:

WBool findNext;
TRUE if the user clicked the Find Next button in the dialog box. Otherwise, it is FALSE (implying a Replace or ReplaceAll operation).
WBool searchDown;
TRUE if the search should proceed down toward the end of the document and FALSE if the search should proceed up toward the beginning of the document.
WBool matchCase;
TRUE if the search should match the case of letters and FALSE if the search should ignore the case of letters.

WBool wholeWord;
TRUE if the search should match whole words, and FALSE if the search may match strings that are part of larger words.
WBool replaceAll;
TRUE if the user clicked the ReplaceAll button and FALSE otherwise.
WBool replace;
TRUE if the user clicked the Replace button and FALSE otherwise.

You can examine these values to determine what kind of search the user wants. Furthermore, you can examine the dialog object to find out the user’s specified search and/or replacement string.

Bis dann.
Martina

bei Antwort benachrichtigen