pb dans la creation d'onglet dans un tabcontrol
Bonjour,
je code en C++ sous Visual Studio 2005 et j'ai créé une classe ContainerTabCtrl de type CTabCtrl.
elle a comme attributs :
Code:
1 2
| int m_DialogID[NB]; // boite de dialogue enfant
CPanelTab *m_Dialog[NB]; // classe associée à la boite de dialogue |
avec NB = 4
j'ai dans mon .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
| //Mon constructeur
ContainerTabCtrl::ContainerTabCtrl()
{
int i =0;
for(i = 0; i < NB; i++)
{
m_Dialog[i] = new CPanelTab();
m_DialogID[i] = IDD_PANEL_INFO_CODE;
}
}
//Destructeur
ContainerTabCtrl::~ContainerTabCtrl()
{
int j = 0;
for(j = 0; j < NB; j++) {delete m_Dialog[j];}
}
//Et mes 2 méthodes
void ContainerTabCtrl::InitDialogs()
{
int k = 0;
for(k = 0; k < NB; k++)
{
m_Dialog[k]->Create(m_DialogID[k],GetParent());
}
}
void ContainerTabCtrl::ActivateTabDialogs(int nSel)
{
int nCount = 0;
if (m_Dialog[nSel]->m_hWnd) {m_Dialog[nSel]->ShowWindow(SW_HIDE);}
CRect l_rectClient;
CRect l_rectWnd;
GetClientRect(l_rectClient);
AdjustRect(FALSE,l_rectClient);
GetWindowRect(l_rectWnd);
GetParent()->ScreenToClient(l_rectWnd);
l_rectClient.OffsetRect(l_rectWnd.left,l_rectWnd.top);
m_Dialog[nSel]->SetWindowPos(&wndTop,
l_rectClient.left,
l_rectClient.top,
l_rectClient.Width(),
l_rectClient.Height(),
SWP_SHOWWINDOW
);
m_Dialog[nSel]->ShowWindow(SW_SHOW);
} |
lorsque je l'appelle dans mon objet parent, j'écris :
Code:
m_TabCtrl.InitDialogs();
Puis:
Code:
1 2 3 4 5
| m_TabCtrl.InsertItem(0,"Main Radio");
m_TabCtrl.InsertItem(1,"Radio 1");
m_TabCtrl.InsertItem(2,"Radio 2");
m_TabCtrl.InsertItem(3,"Radio 3");
m_TabCtrl.SetCurSel(0); |
Et enfin:
Code:
1 2 3 4
| m_TabCtrl.ActivateTabDialogs(0);
m_TabCtrl.ActivateTabDialogs(1);
m_TabCtrl.ActivateTabDialogs(2);
m_TabCtrl.ActivateTabDialogs(3); // m_TabCtrl de type ContainerTabCtrl |
ça compile nickel.
Mais je me retrouve avec le meme onglet instancié 4 fois.
Donc lorsque je saisie qqchose dans les champs texte d'un des onglets, j'ai la meme chose partout.
Pourriez-vous m'aider s'il-vous-plait? Merci d'avance.