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

MFC Discussion :

Probleme Boite Dialog DoModal


Sujet :

MFC

Vue hybride

neoangelo5 Probleme Boite Dialog DoModal 30/06/2011, 10h32
neoangelo5 Problème régler Désoler du... 30/06/2011, 11h42
Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2011
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

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

    Informations forums :
    Inscription : Avril 2011
    Messages : 28
    Par défaut Probleme Boite Dialog DoModal
    Bonjours,
    Je travail sous visual studio 2008
    Je doit faire une boite de dialog avec une comboBox qui propose des choix.
    Je veux mettre cette boite de dialog en Modal car temps que la personne n'a pas valider je ne passe pas à la suite du programe.
    Le probleme si je la met DoModal() quand je veux acceder aux champs de ma comboBox j'ai un message assert Failed.

    Le code : .h
    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
     
    class CDglChoixLamp : public CDialog
    {
        DECLARE_DYNAMIC(CDglChoixLamp)
     
    public:
        CDglChoixLamp(CWnd* pParent = NULL);   // standard constructor
        virtual ~CDglChoixLamp();
     
    // Dialog Data
        enum { IDD = IDD_DIALOGCHOIXLAMPE };
     
    protected:
        //CString cs_FileIni;
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
     
        DECLARE_MESSAGE_MAP()
    public:
        CString getFileIni();
        CComboBox ComboChoixLampe;
        //virtual BOOL OnInitDialog();
        //afx_msg void OnBnClickedOk();
    };
    le code .cpp
    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
    IMPLEMENT_DYNAMIC(CDglChoixLamp, CDialog)
     
    CDglChoixLamp::CDglChoixLamp(CWnd* pParent /*=NULL*/)
        : CDialog(CDglChoixLamp::IDD, pParent)
    {
        /*Create(IDD_DIALOGCHOIXLAMPE,pParent);
        this->SetWindowTextA("Choix Lampe");
        ComboChoixLampe.InsertString(0,"Lampe Prime");
        ComboChoixLampe.InsertString(1,"Lampe S1,S2");
        ComboChoixLampe.SetCurSel(0);*/
     
     
     
     
    }
    /*BOOL CDglChoixLamp::OnInitDialog()
    {
        CDialog::OnInitDialog();
        this->SetWindowTextA("Choix Lampe");
        ComboChoixLampe.InsertString(0,"Lampe Prime");
        ComboChoixLampe.InsertString(1,"Lampe S1,S2");
        ComboChoixLampe.SetCurSel(0);
        UpdateData(FALSE);
        return true;
    }
    */
    CDglChoixLamp::~CDglChoixLamp()
    {
    }
     
    void CDglChoixLamp::DoDataExchange(CDataExchange* pDX)
    {
        CDialog::DoDataExchange(pDX);
        DDX_Control(pDX, IDC_COMBOTYPELAMP, ComboChoixLampe);
    }
     
     
    BEGIN_MESSAGE_MAP(CDglChoixLamp, CDialog)
        //ON_BN_CLICKED(IDOK, &CDglChoixLamp::OnBnClickedOk)
    END_MESSAGE_MAP()
     
     
    // CDglChoixLamp message handlers
     
    /*void CDglChoixLamp::OnBnClickedOk()
    {
        int nIndex=ComboChoixLampe.GetCurSel();
        switch(nIndex){
            case 0:cs_FileIni=".\\LampePrime.ini";
                    break;
            case 1:cs_FileIni=".\\LampeS1S2.ini";
                    break;
            default: cs_FileIni="";
        }
        
        // TODO: Add your control notification handler code here
        OnOK();
    }*/
     
    /*CString CDglChoixLamp::getFileIni(){
        return cs_FileIni;
    }*/
    des chose sont en commentaire car j'essaye plein de possibilité.

    Le code .cpp appelé de ma fonction:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    CDglChoixLamp ChoixFichierINI;
    int nRt=ChoixFichierINI.DoModal();
     
        if(nRt==IDOK){
            CString str;
            ChoixFichierINI.ComboChoixLampe.GetCurSel();
        }
    Une personne aurait une idée ?

  2. #2
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2011
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

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

    Informations forums :
    Inscription : Avril 2011
    Messages : 28
    Par défaut
    Problème régler Désoler du dérangement
    Solution :
    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
    if(bWorking==true){
    		do
    		{
    			CDglChoixLamp ChoixFichierINI;
    			int nRt=ChoixFichierINI.DoModal();
     
    			if(nRt==IDOK){
    				CString str;
    				str=".\\";
    				cs_cheminFileIni=ChoixFichierINI.getFileIni();
    				cs_cheminFileIni=str+cs_cheminFileIni;
    				DlgOptionAvance->setFileIni(cs_cheminFileIni);
    				Sortie=true;
    			}
    		}while(Sortie!=true);
    	}


    code .h
    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
    CDglChoixLamp::CDglChoixLamp(CWnd* pParent /*=NULL*/)
    	: CDialog(CDglChoixLamp::IDD, pParent)
    	, strChoixLampe(_T(""))
    {
    }
    BOOL CDglChoixLamp::OnInitDialog()
    {
    	CDialog::OnInitDialog();
    	this->SetWindowTextA("Choix Lampe");
    	CFileFind finder;
    	BOOL bWorking = finder.FindFile ("*.ini");
    	int nIndex=0;
    	CString nomFichier;
    	 while (bWorking)
        {
           bWorking = finder.FindNextFile ();
    	   nomFichier=finder.GetFileName ();
     
    	   ComboChoixLampe.InsertString(nIndex,nomFichier);
    	   ComboChoixLampe.UpdateData();
    		nIndex++;
        }
    	ComboChoixLampe.SetCurSel(0);
    	UpdateData(true);
    	return true;
    }
     
    CDglChoixLamp::~CDglChoixLamp()
    {
    }
     
    void CDglChoixLamp::DoDataExchange(CDataExchange* pDX)
    {
    	CDialog::DoDataExchange(pDX);
    	DDX_Control(pDX, IDC_COMBOTYPELAMP, ComboChoixLampe);
    	DDX_CBString(pDX, IDC_COMBOTYPELAMP, strChoixLampe);
    }
     
     
    BEGIN_MESSAGE_MAP(CDglChoixLamp, CDialog)
    	//ON_BN_CLICKED(IDOK, &CDglChoixLamp::OnBnClickedOk)
    END_MESSAGE_MAP()
     
     
    // CDglChoixLamp message handlers
     
     
     
    CString CDglChoixLamp::getFileIni(){
     
    	return strChoixLampe;
    }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Image & boite dialog
    Par meera dans le forum Visual C++
    Réponses: 1
    Dernier message: 03/10/2006, 15h22
  2. [boit dialog] modif txt bouton ok et annuler
    Par harlock59 dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 10/07/2006, 14h16
  3. Probleme boite de dialogue MFC
    Par beb30 dans le forum MFC
    Réponses: 5
    Dernier message: 13/04/2006, 15h42
  4. [VB6]Probleme Common Dialog
    Par ganon551 dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 12/02/2006, 12h04

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