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
|
int Q=0;
#define NBQUESTIONS 3
AnsiString Questions[] = {"Question 1: ...",
"Question 2: ...",
"Question 3: ..."};
AnsiString Reponse1[] = {"Q1,R1","Q1,R2","Q1,R3"};
AnsiString Reponse2[] = {"Q2,R1","Q2,R2",""};
AnsiString Reponse3[] = {"Q3,R1","Q3,R2","Q3,R3"};
AnsiString *Reponses[] = {Reponse1, Reponse2, Reponse3};
TCheckBox *CheckBox[3];
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Button1->Caption = "Précédent";
Button2->Caption = "Suivant";
Button1->Visible = false;
CheckBox[0] = Form1->CheckBox1;
CheckBox[1] = Form1->CheckBox2;
CheckBox[2] = Form1->CheckBox3;
GroupBox1->Caption = "Question " + IntToStr(Q+1) + "/" + IntToStr(NBQUESTIONS);
Label1->Caption = Questions[Q];
for(int i=0;i<3;i++)
{
CheckBox[i]->Visible = true;
if(Reponses[Q][i] != "") CheckBox[i]->Caption = Reponses[Q][i];
else CheckBox[i]->Visible = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Button1->Visible = true;
Q++;
Label1->Caption = Questions[Q];
GroupBox1->Caption = "Question " + IntToStr(Q+1) + "/" + IntToStr(NBQUESTIONS);
for(int i=0;i<3;i++)
{
CheckBox[i]->Visible = true;
if(Reponses[Q][i] != "") CheckBox[i]->Caption = Reponses[Q][i];
else CheckBox[i]->Visible = false;
}
if(Q == NBQUESTIONS-1) Button2->Visible = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Button2->Visible = true;
Q--;
Label1->Caption = Questions[Q];
GroupBox1->Caption = "Question " + IntToStr(Q+1) + "/" + IntToStr(NBQUESTIONS);
for(int i=0;i<3;i++)
{
CheckBox[i]->Visible = true;
if(Reponses[Q][i] != "") CheckBox[i]->Caption = Reponses[Q][i];
else CheckBox[i]->Visible = false;
}
if(Q == 0) Button1->Visible = false;
}
//--------------------------------------------------------------------------- |
Partager