Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

//<pre>CConnecterView.cpp

void CConnecterView::OnInitialUpdate()
{
	CTreeView::OnInitialUpdate();
	globalVar= false;
	UpdateData(TRUE);
	CTreeCtrl& tc = GetTreeCtrl();
	//CTreeCtrl& tc1 = GetTreeCtrl();
	// Set tree control styles
	//globalVar = false;
	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;
	//HTREEITEM m_hdeconnecter;
	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;
		//Métrologie
		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);
		//Métrologie légale
		hIns = tc.InsertItem(_T("Instantanées"), hML);
		hEn = tc.InsertItem(_T("Energies"), hML);
		//Métrologie Non légale
		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);
		//Relais
		hRe = tc.InsertItem(_T("Relais"), TVI_ROOT);

		//Calendrier Tarifaire
		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);
		//Horodate
		hHor = tc.InsertItem(_T("Horodate "), TVI_ROOT);
		//Facturetion
		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);
		//Surveillance
		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);

		//Affichage
		hAff = tc.InsertItem(_T("Afficahge "), TVI_ROOT);
		//Communication
		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 ;
		//pMainFrame->pTreeView->m_ctrlTree.Update();
		//UpdateData(TRUE);
	}
	UpdateData(FALSE);
}
Posted
Updated 4-Sep-18 22:13pm
Comments
Richard MacCutchan 5-Sep-18 5:28am    
You need to send a message to the TreeView to tell it to update its content.

And the statement globalVar ; does not mean anything.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900