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:
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:
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:
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 ?