Link to home
Start Free TrialLog in
Avatar of Imen BELTAIEF
Imen BELTAIEF

asked on

Tree Item command

I create my tree using the code a bellow :
//Create my own Tree(Items + Sub Items)
BOOL CIntAccDlg::OnInitDialog()
{
      CDialogEx::OnInitDialog();
      HTREEITEM hMétrologie, hSurveillance, hHisOuverture, hHisDépassementTempérature, hHisMiseTerre, hLogResetsHis , hMetrologieLegale,hRelais, hCourbeDeCharge, hGlissProgrammé ,hHorodate, hFacturation, hStructureActive, hGlissPeriodique,hStructurePassivective, hJoursFériés, hCalendrierTarifaire, hInstantanée, hMetrologieNonLegale, hEnergie, hMoyenne,hMaximas,hContrat,hExursionTension
      , hCoupures,hCommunication, hCléAESGCM, hCléCrypAUTHGCM, hParPhyPortLocal, hHDLCPortLocal, hParPhyPortSerie, hParHDLCPortSerie, hImporter, hExporter, hImprimer;
      
      //Métrologie
      hMétrologie = m_treeCtrl.InsertItem(_T("Métrologie"), TVI_ROOT);
      hMetrologieLegale = m_treeCtrl.InsertItem(_T("Métrologie Légale"), hMétrologie);
      hMetrologieNonLegale = m_treeCtrl.InsertItem(_T("Métrologie Non Légale"), hMétrologie);
      //Métrologie légale
      hInstantanée = m_treeCtrl.InsertItem(_T("Instantanées "), hMetrologieLegale);
      hEnergie = m_treeCtrl.InsertItem(_T("Energies "), hMetrologieLegale);
      //Métrologie Non légale
      hMoyenne = m_treeCtrl.InsertItem(_T("Moyennes "), hMetrologieNonLegale);
      hMaximas = m_treeCtrl.InsertItem(_T("Maximas "), hMetrologieNonLegale);
      hContrat = m_treeCtrl.InsertItem(_T("Contrat "), hMetrologieNonLegale);
      hExursionTension = m_treeCtrl.InsertItem(_T("Excursion de tension "), hMetrologieNonLegale);
      //Relais
      hRelais= m_treeCtrl.InsertItem(_T("Relais "), TVI_ROOT);.

// Click the item "hMetrologieLegale" to display the dialog box related to this item.

UINT uFlags;
      POINT myPoint;
      myPoint.x = 0;
      myPoint.y = 0;
      HTREEITEM hItem = m_treeCtrl.HitTest(myPoint, &uFlags);

      if ((hItem != NULL) && (TVHT_ONITEM & uFlags))
      {
            m_treeCtrl.SelectItem(hItem);
            if (hItem == hMetrologieLegale)
            {
                  m_aff.CreateSubForm(IDD_DIALOG_Test1, this);
                  m_aff.ShowSubForm();
            }
      }


Which I need now is to set action to Items and Sub Items . By clicking in one item , a dialog box is showed with specification related to the selected clicked item .
I try with those code , but unfortunately .
Is there any code which satisfy my need .
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.