1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| #include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int position;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int op=1;
while(op<=6)
{ switch(op)
{
case 1: position=Memo1->Lines->Text.Pos("les");
if (position!=0)
{Memo1->SetFocus();
Memo1->SelStart=position-1;
Memo1->SelLength=3;
Memo1->ClearSelection(); op++; break;
}else {op++;break; }
case 2: position=Memo1->Lines->Text.Pos("le");
if (position!=0)
{Memo1->SetFocus();
Memo1->SelStart=position-1;
Memo1->SelLength=2;
Memo1->ClearSelection(); op++; break;
}
else {op++;break; }
case 3: position=Memo1->Lines->Text.Pos("la");
if (position!=0)
{Memo1->SetFocus();
Memo1->SelStart=position-1;
Memo1->SelLength=2;
Memo1->ClearSelection(); op++; break;
}
else {op++;break; }
case 4: position=Memo1->Lines->Text.Pos("une");
if (position!=0)
{Memo1->SetFocus();
Memo1->SelStart=position-1;
Memo1->SelLength=3;
Memo1->ClearSelection(); op++; break;
}else {op++;break; }
case 5: position=Memo1->Lines->Text.Pos("un");
if (position!=0)
{Memo1->SetFocus();
Memo1->SelStart=position-1;
Memo1->SelLength=2;
Memo1->ClearSelection(); op++; break;
}
else {op++;break; }
default : position=Memo1->Lines->Text.Pos("des");
if (position!=0)
{Memo1->SetFocus();
Memo1->SelStart=position-1;
Memo1->SelLength=3;
Memo1->ClearSelection(); op++; break;
}
else {op++;break; }
}
}
Button1Click(Sender);
} |
Partager