CMap ,CList的应用

CMap <INT, INT&,CList <CWnd *, CWnd *> *, CList<CWnd *, CWnd *> *> m_PageToCtrlListMap;//

 

CList <CWnd *, CWnd *> * pCtrlList = NULL;

 if(!m_PageToCtrlListMap.Lookup(n,pCtrlList) || !pCtrlList)//获取Key=n的数据地址给pCtrlList

 {
      pCtrlList = new CList <CWnd *, CWnd *>;
      m_PageToCtrlListMap.SetAt(n, pCtrlList);//key为n处添加对像pCtrlList
 }

 pCtrlList -> AddTail(pControl);//给pCtrlList存放数据

 

 

 

 

 POSITION Pos[2] = { m_PageToCtrlListMap.GetStartPosition(), NULL };
 CList <CWnd *, CWnd *> * pCtrlList = NULL;
 CWnd * pCtrl = NULL;
 INT rKey (0);

 while(Pos[0])
 {
    m_PageToCtrlListMap.GetNextAssoc(Pos[0],rKey,pCtrlList);//获取CMap数据

    Pos[1] = pCtrlList -> GetHeadPosition();

    while(Pos[1])
    {
       pCtrl = pCtrlList -> GetNext(Pos[1]);//获取对应相的CList数据
       ::ShowWindow(pCtrl -> GetSafeHwnd(), nCurrSel == rKey ? SW_SHOW : SW_HIDE );
    }
 }

你可能感兴趣的:(CMap ,CList的应用)