IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

identificateur non déclaré


Sujet :

C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Novembre 2012
    Messages : 17
    Par défaut identificateur non déclaré
    Bonjour a tous,

    J'ai une erreur de compilation et je trouve pas la solution.J'ai 5 form,j'arrive a faire appeler tous les form via un bouton sauf celui ci.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    #include "Form_Web.h"
     
    using namespace std;
    namespace Logiciel_WebVersion {
     
    private: System::Void btn_ConfirmMission_Click(System::Object^  sender, System::EventArgs^  e) {
     
    Form_Web^ fw= gcnew Form_Web();
     
    }
    }

    Erreur 14 error C2065: 'fw'*: identificateur non déclaré
    Erreur 13 error C2065: 'Form_Web'*: identificateur non déclaré
    Erreur 15 error C2061: erreur de syntaxe*: identificateur 'Form_Web'
    Merci en avance

  2. #2
    Membre émérite
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2014
    Messages
    345
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2014
    Messages : 345
    Par défaut
    Bonjour,

    Peux-tu poster le contenu de Form_Web.h ?

  3. #3
    Membre averti
    Femme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Novembre 2012
    Messages : 17
    Par défaut
    Oui biensur,
    Voici la form_web.rien d'extraordinaire.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    #pragma once
    #include "stdafx.h"
    #include "Form_Logiciel.h"
     
     
    using namespace std;
    namespace Logiciel_WebVersion {
     
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace System::IO;
    using namespace System::Xml;
    using namespace System::Text::RegularExpressions;
    using namespace System::Threading;
     
    int CPT;
     
    /// <summary>
    /// Description résumée de Form_Web
    /// </summary>
    public ref class Form_Web : public System::Windows::Forms::Form
    {
     
    private: System::Windows::Forms::Label^  label_aller;
    private: System::Windows::Forms::WebBrowser^  webBrowser1;
    private: System::Windows::Forms::Label^  label_prendre;
    private: System::Windows::Forms::Label^  label_amener;
    private: System::Windows::Forms::Label^  label_poser;
     
    private: System::Windows::Forms::Timer^  timer_refresh;
     
    public:
    	Form_Web(void)
    	{
    		InitializeComponent();
    		//
    		//TODO: ajoutez ici le code du constructeur
    		//
    	}
     
    protected:
    	/// <summary>
    	/// Nettoyage des ressources utilisées.
    	/// </summary>
    	~Form_Web()
    	{
    		if (components)
    		{
    			delete components;
    		}
    	}
    private: System::ComponentModel::IContainer^  components;
     
    private:
    	/// <summary>
    	/// Variable nécessaire au concepteur.
    	/// </summary>
     
     
    #pragma region Windows Form Designer generated code
    	/// <summary>
    	/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
    	/// le contenu de cette méthode avec l'éditeur de code.
    	/// </summary>
    	void InitializeComponent(void)
    	{
    		this->components = (gcnew System::ComponentModel::Container());
    		this->label_aller = (gcnew System::Windows::Forms::Label());
    		this->webBrowser1 = (gcnew System::Windows::Forms::WebBrowser());
    		this->label_prendre = (gcnew System::Windows::Forms::Label());
    		this->label_amener = (gcnew System::Windows::Forms::Label());
    		this->label_poser = (gcnew System::Windows::Forms::Label());
    		this->timer_refresh = (gcnew System::Windows::Forms::Timer(this->components));
    		this->SuspendLayout();
    		// 
    		// label_aller
    		// 
    		this->label_aller->AutoSize = true;
    		this->label_aller->Location = System::Drawing::Point(49, 468);
    		this->label_aller->Name = L"label_aller";
    		this->label_aller->Size = System::Drawing::Size(26, 13);
    		this->label_aller->TabIndex = 1;
    		this->label_aller->Text = L"aller";
    		// 
    		// webBrowser1
    		// 
    		this->webBrowser1->Location = System::Drawing::Point(34, 21);
    		this->webBrowser1->MinimumSize = System::Drawing::Size(20, 20);
    		this->webBrowser1->Name = L"webBrowser1";
    		this->webBrowser1->Size = System::Drawing::Size(744, 411);
    		this->webBrowser1->TabIndex = 2;
    		this->webBrowser1->Url = (gcnew System::Uri(L"http://localhost/toto/", System::UriKind::Absolute));
    		this->webBrowser1->DocumentCompleted += gcnew System::Windows::Forms::WebBrowserDocumentCompletedEventHandler(this, &Form_Web::webBrowser1_DocumentCompleted);
    		// 
    		// label_prendre
    		// 
    		this->label_prendre->AutoSize = true;
    		this->label_prendre->Location = System::Drawing::Point(314, 468);
    		this->label_prendre->Name = L"label_prendre";
    		this->label_prendre->Size = System::Drawing::Size(43, 13);
    		this->label_prendre->TabIndex = 3;
    		this->label_prendre->Text = L"prendre";
    		// 
    		// label_amener
    		// 
    		this->label_amener->AutoSize = true;
    		this->label_amener->Location = System::Drawing::Point(573, 468);
    		this->label_amener->Name = L"label_amener";
    		this->label_amener->Size = System::Drawing::Size(42, 13);
    		this->label_amener->TabIndex = 4;
    		this->label_amener->Text = L"amener";
    		// 
    		// label_poser
    		// 
    		this->label_poser->AutoSize = true;
    		this->label_poser->Location = System::Drawing::Point(810, 468);
    		this->label_poser->Name = L"label_poser";
    		this->label_poser->Size = System::Drawing::Size(33, 13);
    		this->label_poser->TabIndex = 5;
    		this->label_poser->Text = L"poser";
    		// 
    		// timer_refresh
    		// 
    		this->timer_refresh->Interval = 2000;
    		this->timer_refresh->Tick += gcnew System::EventHandler(this, &Form_Web::timer_refresh_Tick);
    		// 
    		// Form_Web
    		// 
    		this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    		this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    		this->ClientSize = System::Drawing::Size(922, 507);
    		this->Controls->Add(this->label_poser);
    		this->Controls->Add(this->label_amener);
    		this->Controls->Add(this->label_prendre);
    		this->Controls->Add(this->webBrowser1);
    		this->Controls->Add(this->label_aller);
    		this->Name = L"Form_Web";
    		this->Text = L"Form_Web";
    		this->Load += gcnew System::EventHandler(this, &Form_Web::Form_Web_Load);
    		this->ResumeLayout(false);
    		this->PerformLayout();
     
    	}
    #pragma endregion
     
     
    private: System::Void webBrowser1_DocumentCompleted(System::Object^  sender, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^  e) {
     
    			CPT=CPT+1;			 
    				if (CPT==1) { 
    					devicenamerecup=devicenamerecup->Substring(3,devicenamerecup->Length-3);
    					SendKeys::Send(devicenamerecup);
    					Sleep(500);
    					SendKeys::Send("{enter}");
    				}
    				if (CPT==2) {
    					SendKeys::Send(userrecup);
    							SendKeys::Send("{tab}");
    					Sleep(500);
    					SendKeys::Send(mdprecup);
    					Sleep(500);
    					SendKeys::Send("{enter}");
    				}
    				if (CPT==3) {
    					SendKeys::Send("{tab}");
    					Sleep(500);
    					SendKeys::Send("{enter}");
    				}
     
     
     
    				if (CPT==4) {
    					Form_Logiciel^ formlogiciel = gcnew Form_Logiciel();
    					formlogiciel ->Show();	
     
    				}
    			}
    Quand la variable cpt ==4 il arrive a bien afficher le form_logiciel

  4. #4
    Membre émérite
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2014
    Messages
    345
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2014
    Messages : 345
    Par défaut
    Citation Envoyé par neterfari Voir le message
    Quand la variable cpt ==4 il arrive a bien afficher le form_logiciel
    Je n'ai pas compris.

    Bon sinon ça fait un bail que j'ai pas touché à du VC++, c'est normal que tout le code soit dans un .h ?
    Si le code du premier post était celui de Form_Logiciel.h, alors tu as peut-être le problème des deux headers qui s'incluent mutuellement.
    Comme Form_Logiciel.h inclut Form_Web.h qui lui-même inclut Form_Logiciel.h avant de déclarer Form_Web, lors de la compilation de Form_Logiciel, Form_Web n'existe pas encore.
    Pour pallier à ça il te faut déclarer Form_Web juste avant Form_Logiciel :

    (à confirmer.)

  5. #5
    Membre averti
    Femme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Novembre 2012
    Messages : 17
    Par défaut
    oui c'est normal que tout le code est dans un .h pour mon programme .

    Le code du premier appartient à Form_Logiciel.h.

    La form_web est crére avant la form_logiciel et inclure un form qui n'existe pas encore ça ne pose pas de problème.

    Preuve:ce code qui se trouve dans form_web fonctionne parfaitement. Form_logiciel n'existe pas encore.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Form_Logiciel^ formlogiciel = gcnew Form_Logiciel();
     
    formlogiciel ->Show();

  6. #6
    Membre émérite
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2014
    Messages
    345
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2014
    Messages : 345
    Par défaut
    Quand je disais "existe" c'était "existe du point de vue du compilateur". Pas lors de l'exécution.
    Le code que tu me donnes en exemple est ok parce que le compilateur sait, au moment où il rencontre ces lignes de code, ce qu'est Form_Logiciel.
    Ce n'est pas le cas avec Form_Web, pour les raisons que j'ai citées précédemment.
    As-tu essayé la solution que je t'ai proposé ? Quels sont les résultats ?

    PS: un programme C++ entièrement dans des .h, ce n'est pas normal.

  7. #7
    Membre émérite
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2014
    Messages
    345
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Juin 2014
    Messages : 345
    Par défaut
    Citation Envoyé par neterfari Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    #include "Form_Web.h"
     
    using namespace std;
    namespace Logiciel_WebVersion {
     
    private: System::Void btn_ConfirmMission_Click(System::Object^  sender, System::EventArgs^  e) {
     
    Form_Web^ fw= gcnew Form_Web();
     
    }
    }
    Ce code c'est l'original ? btn_ConfirmMission_Click n'est pas censé être dans une classe ?

  8. #8
    Membre averti
    Femme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Novembre 2012
    Messages : 17
    Par défaut
    Si si il est dans une class comme celui ci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    #include "Form_Web.h"
     
    using namespace std;
    namespace Logiciel_WebVersion {
     public ref class Form_Logiciel : public System::Windows::Forms::Form
    	{
    private: System::Void btn_ConfirmMission_Click(System::Object^  sender, System::EventArgs^  e) {
     
    Form_Web^ fw= gcnew Form_Web();
     
    }
    }
    }

Discussions similaires

  1. [D5] Identificateur non déclaré
    Par MelkInarian dans le forum Delphi
    Réponses: 2
    Dernier message: 20/04/2007, 17h20
  2. findcomponent, identificateur non déclaré
    Par chourmo dans le forum Delphi
    Réponses: 3
    Dernier message: 04/07/2006, 13h54
  3. Identificateur non déclaré
    Par nisere dans le forum Langage
    Réponses: 2
    Dernier message: 21/03/2006, 09h33
  4. Identificateur non déclaré : 'Null'
    Par Mofid04 dans le forum Bases de données
    Réponses: 4
    Dernier message: 12/03/2006, 11h47
  5. Problème d'identificateur non déclaré
    Par renorx dans le forum Débuter
    Réponses: 3
    Dernier message: 14/11/2005, 20h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo