示例#1
0
static VOID
EnumChildDevices(HWND hTreeView,
                 HTREEITEM hRoot,
                 DEVINST dnParentDevInst,
                 BOOL bShowHidden)
{
    HTREEITEM hDevItem;
    DEVINST dnDevInst;
    CONFIGRET cr;

    cr = CM_Get_Child(&dnDevInst,
                      dnParentDevInst,
                      0);
    if (cr != CR_SUCCESS)
        return;

    hDevItem = AddDeviceToTree(hTreeView,
                               hRoot,
                               dnDevInst,
                               bShowHidden);
    if (hDevItem != NULL)
    {
        EnumChildDevices(hTreeView,
                         hDevItem,
                         dnDevInst,
                         bShowHidden);
    }

    while (cr == CR_SUCCESS)
    {
        cr = CM_Get_Sibling(&dnDevInst,
                            dnDevInst,
                            0);
        if (cr != CR_SUCCESS)
            break;

        hDevItem = AddDeviceToTree(hTreeView,
                                   hRoot,
                                   dnDevInst,
                                   bShowHidden);
        if (hDevItem != NULL)
        {
            EnumChildDevices(hTreeView,
                             hDevItem,
                             dnDevInst,
                             bShowHidden);
        }
    }

    (void)TreeView_SortChildren(hTreeView,
                                hRoot,
                                0);
}
示例#2
0
void CMyTreeView::UpdateView(void)
{
    int iRegionCount = 0;
    TagRegion region = {0};
    HTREEITEM hTemp;

    CTreeCtrl* p_tree = g_GlobalData.m_tree;
    p_tree->DeleteAllItems();

    HTREEITEM hRegionRoot = p_tree->InsertItem(_T("区域"), TVI_ROOT);
    p_tree->SetItemData(hRegionRoot, 0);    

    iRegionCount = getTblRecordCount(EH_TBL_REGION);
    for (int i = 0; i < iRegionCount; i++) {
        fetchRecordData(EH_TBL_REGION, i, &region);
        hTemp = p_tree->InsertItem(region.desc, hRegionRoot);

        p_tree->SetItemData(hTemp, 1);  
        
        //addDevice to tree
        AddDeviceToTree(hTemp, region.id);
    }
}