TextBox avec plusieurs Windows Form
Salut � tous,
J'ai une interface ou j'ai plusieurs textbox et je r�cup�re leur valeur dans une fonction dans class Form2.
Cependant vu que j'aurais les m�mes textbox dans plusieurs interfaces j'aurais voulu faire une fonction g�n�rique qui r�cup�re les donn�es selon l'interface utilis�.
Dans form2.cpp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| String^Form2::valeur_limites()
{
String^ min_ab; String^ max_ab; String^ pas_ab; String^ min_or; String^ max_or; String^ pas_or;
String^ total;
min_ab=textBox_min_ab->Text->ToString();
max_ab=textBox_max_ab->Text->ToString();
pas_ab=textBox_pas_ab->Text->ToString();
min_or=textBox_min_or->Text->ToString();
max_or=textBox_max_or->Text->ToString();
pas_or=textBox_pas_or->Text->ToString();
total="x"+" "+min_ab+" "+max_ab+" "+pas_ab+" "+min_or+" "+max_or+" "+pas_or+" ";
return total;
} |
Dans communication.cpp : (l� o� sont mes fonctions g�n�riques)
Code:
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
| int* Limites()
{
Form2 gForm2;
String^limites;
char* lim;
if (type_gene==0)
{
//on r�cup�re les donn�es de l'interface teleview
}
if (type_gene==1)
{
//on r�cup�re les donn�es de l'interface dektek
limites=gForm2.valeur_limites();
}
//convertit un string en char
lim= (char*)(void*)Marshal::StringToHGlobalAnsi(limites);
char* pt=lim; static char argv[32][32]; char* pargv[7];
//on d�cortique la chaine total pour avoir les valeurs des limites
int i = 0;
int num[6];
while (true)
{
pt = strstr(lim, " "); // find space
if (pt == 0) // space not find
{
strcpy(argv[i++], lim); // last command
break; // end of cmd
}
*pt = 0; // end of string
strcpy(argv[i++], lim); // one command
pargv[i] = &argv[i][0]; // init pointer
*pt++; // next command
strcpy(lim, pt); // erase previous command
}
// on convertit les char en int
num[0] = atoi(pargv[1]); // freq min -> Abcisse Min
num[1] = atoi(pargv[2]); // freq max -> Abscisse Max
num[2] = atoi(pargv[3]); // pas freq -> Abcisse Pas
num[3] = atoi(pargv[4]); // niveau min -> Ordonn�e Min
num[4] = atoi(pargv[5]); // niveau max -> Ordonn�e Max
num[5] = atoi(pargv[6]); // pas niveau -> Ordonn�e Pas
return num;
} |
Le soucis lorsque j�ex�cute c'est que dans les variables qui r�cup�rent les valeurs (min-ab, max_ab...), sont vides (leurs valeurs: "").
Je ne comprend absolument pas pourquoi.
Quelqu'un a une id�e?