[Winforms]Variables globales entre forms
Bonjour !
Alors voil� je cherche je cherche mais je ne trouve de solution nulle part...
J'utilise la m�thode d�crite ici, cela fonctionne bien. J'ai includ� le fichier Globals.h contenant la m�thode dans stdafx.h, juste avant #pragma once.
En-t�te Globals :
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 50 51 52 53 54 55 56 57 58 59 60 61 62
| public ref class SharedVariables
{
private:
//STATIC VARIABLES
static System::String ^Function;
static System::String ^Project;
static System::String ^ProjectTrigList;
static System::String ^ProjectEvntList;
public:
static property String ^CurrentFunction
{
String^ get()
{
return Function;
}
void set(String^ value)
{
CurrentFunction = value;
}
}
static property String ^CurrentProject
{
String^ get()
{
return Project;
}
void set(String^ value)
{
CurrentProject = value;
}
}
static property String ^CurrentProjectTrigList
{
String^ get()
{
return ProjectTrigList;
}
void set(String^ value)
{
CurrentProjectTrigList = value;
}
}
static property String ^CurrentProjectEvntList
{
String^ get()
{
return ProjectEvntList;
}
void set(String^ value)
{
CurrentProjectEvntList = value;
}
}
}; |
D�s que je touche � CurrentProjectTrigList avec 'set', le programme rencontre une erreur : Une exception non g�r�e du type 'System.StackOverflowException' s'est produite dans Heroes V GUI Trigger Editor.exe
Par contre, CurrentProject est utilis� avec 'set' sans probl�mes juste avant. Et dans la pile des appels, il n'y a qu'une suite interminable de
> Heroes V GUI Trigger Editor.exe!SharedVariables::set_CurrentFunction(System::String^ value = <valeur non d�finie>) Ligne 19 + 0xffffffef octets C++
Utilisation des variables :
Code:
1 2 3 4 5 6 7 8 9
| System::String ^CurrentProjectName;
System::IO::StreamReader ^sr = gcnew System::IO::StreamReader("TMP.txt");
System::IO::Directory::CreateDirectory("Projects\\");
CurrentProjectName = sr->ReadToEnd()->ToString();
SharedVariables::CurrentProject = ("Projects\\" + CurrentProjectName + ".h5t");
SharedVariables::CurrentProjectTrigList = ("Projects\\" + CurrentProjectName + ".triglist");
SharedVariables::CurrentProjectEvntList = ("Projects\\" + CurrentProjectName + ".evntlist");
sr->Close(); |
Je ne comprends pas... :(
Aussi dans les avertissement du d�boggage, il y a :
Avertissement 1 warning C4717: 'SharedVariables::CurrentFunction::set' : r�current sur tous les chemins d'acc�s de contr�le, la fonction entra�nera un d�passement de capacit� de la pile d'ex�cution c:\users\raftadata\documents\visual studio 2008\projects\heroes v gui trigger editor\heroes v gui trigger editor\globals.h 20
Mais coment faire alors pour mes variables globales � toutes les forms ?