Hello , I have the problem described as below :
I have a treeview in left pane and a right pane to display the different views related to the clicked tree items.
First :just one item of the true should be displayed in the left pane.then by validating the authentication step ,the other tree items should be added to the first tree item .
so by clicking in the tree item "Connecter" , a view is displayed in the right pane :an authentication step , by validating the username and the PSW , the other tree items are added to the left pane.
the authentication view is for the CForm Class :
My problem is that by validating the authentication step , the other tree item didn't added to the left pane .
I try with a global variable to get notification of the authentication step , then based in it I will show all tree items or just the first item.
What I have tried:
void CConnecterView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
globalVar= false;
UpdateData(TRUE);
CTreeCtrl& tc = GetTreeCtrl();
long style = GetWindowLong(tc.m_hWnd, GWL_STYLE);
style |= (TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS |
TVS_SHOWSELALWAYS | TVS_DISABLEDRAGDROP);
SetWindowLong(tc.m_hWnd, GWL_STYLE, style);
HTREEITEM m_hCoonecter;
HTREEITEM m_hDefault;
m_hDefault = tc.InsertItem(_T(""), TVI_ROOT);
m_hCoonecter = tc.InsertItem(_T("Connecter"), TVI_ROOT);
if (!globalVar)
{
HTREEITEM hM, hML, hMNL, hIns, hEn, hMoy, hMax, hCon, hExT, hRe, hCaT, hSAc, hSPa, hJFe, hHor, hFac, hGPe, hGPr, hCDC, hCoupures, hSur, hHisOuverture, hHisDépassementTempérature, hHisMiseTerre, hLogResetsHis, hAff, hCom, hCléAESGCM, hCléCrypAUTHGCM, hParPhyPortLocal, hHDLCPortLocal, hParPhyPortSerie, hParHDLCPortSerie, hImporter, hExporter, hImprimer;
hM = tc.InsertItem(_T("Métrologie"), TVI_ROOT);
hML = tc.InsertItem(_T("Métrologie Légale"), hM);
hMNL = tc.InsertItem(_T("Métrologie Non Légale"), hM);
hIns = tc.InsertItem(_T("Instantanées"), hML);
hEn = tc.InsertItem(_T("Energies"), hML);
hMoy = tc.InsertItem(_T("Moyennes"), hMNL);
hMax = tc.InsertItem(_T("Maximas"), hMNL);
hCon = tc.InsertItem(_T("Contrat "), hMNL);
hExT = tc.InsertItem(_T("Excursion de tension"), hMNL);
hRe = tc.InsertItem(_T("Relais"), TVI_ROOT);
hCaT = tc.InsertItem(_T("Calendrier Tarifaire "), TVI_ROOT);
hSAc = tc.InsertItem(_T("Structure Active"), hCaT);
hSPa = tc.InsertItem(_T("Structure Passive"), hCaT);
hJFe = tc.InsertItem(_T("Jours Fériés"), hCaT);
hHor = tc.InsertItem(_T("Horodate "), TVI_ROOT);
hFac = tc.InsertItem(_T("Facturation "), TVI_ROOT);
hGPe = tc.InsertItem(_T("Glissement periodique "), hFac);
hGPr = tc.InsertItem(_T("Glissement programmé "), hFac);
hCDC = tc.InsertItem(_T("Courbe de cahrge "), hFac);
hCoupures = tc.InsertItem(_T("Coupures "), hFac);
hSur = tc.InsertItem(_T("Surveillance "), TVI_ROOT);
hHisOuverture = tc.InsertItem(_T("Historique d'Ouverture "), hSur);
hHisDépassementTempérature = tc.InsertItem(_T("Historique de Dépassement de la Température "), hSur);
hHisMiseTerre = tc.InsertItem(_T("Historique de mise à terre "), hSur);
hLogResetsHis = tc.InsertItem(_T("Log des Resets des historiques "), hSur);
hAff = tc.InsertItem(_T("Afficahge "), TVI_ROOT);
hCom = tc.InsertItem(_T("Security policy "), TVI_ROOT);
hCléAESGCM = tc.InsertItem(_T("CléAES/GCM "), hCom);
hCléCrypAUTHGCM = tc.InsertItem(_T("Clé Crypto AUTH pour GCM "), hCom);
hParPhyPortLocal = tc.InsertItem(_T("Paramètres physiques du port local "), hCom);
hHDLCPortLocal = tc.InsertItem(_T("Paramètres HDLC du port local "), hCom);
hParPhyPortSerie = tc.InsertItem(_T("Paramètres physiques du port série "), hCom);
hParHDLCPortSerie = tc.InsertItem(_T("Paramètres HDLC du port série"), hCom);
hImporter = tc.InsertItem(_T("Importer "), TVI_ROOT);
hExporter = tc.InsertItem(_T("Exporter "), TVI_ROOT);
hImprimer = tc.InsertItem(_T("Imprimer "), TVI_ROOT);
UpdateData(FALSE);
}
}
#endif //_DEBUG
// CForm.cpp
void CForm::OnBnClickedButton1()
{
UpdateData(TRUE);
CMainFrame *pMainFrame = (CMainFrame*)AfxGetMainWnd();
if (m_User_Login == "admin" && m_User_Psw == "admin")
{
globalVar ;
}
UpdateData(FALSE);
}