日期:2012-09-04  浏览次数:20390 次

//////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CMClientDlg::AddtoTree()
//
//  parameters: (HTREEITEM hParent, HTREEITEM hInsertAfter, LPTSTR pszData, UINT mask, IUnknown
//              * theInterface)
//
//  description: insert the tree item to Tree
//
//  returns: HTREEITEM
//
//////////////////////////////////////////////////////////////////////////////////////////////////
HTREEITEM CMClientDlg::AddtoTree(HTREEITEM hParent, HTREEITEM hInsertAfter, LPTSTR pszData, UINT mask,
                                 IUnknown * theInterface)
{
    TV_INSERTSTRUCT            curTreeItem;
    HTREEITEM                hReturn;
    
    curTreeItem.hParent = hParent;
    curTreeItem.hInsertAfter = hInsertAfter;
    curTreeItem.item.pszText = pszData;
    curTreeItem.item.mask = mask |LVIF_PARAM;
    curTreeItem.item.lParam = reinterpret_cast<DWORD>(theInterface);

    hReturn = m_TreeCtrl.InsertItem(&curTreeItem);
// if insertion  fails , it will return NULL, otherwise it will return Handle of the new item,
    if  (hReturn)
        theInterface->AddRef();

    return hReturn;
}

//////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CMClientDlg::nCountParameter()
//
//  parameters: No Parameters
//
//  description: counts the number of parameters, the function takes
//  returns: int
//
//////////////////////////////////////////////////////////////////////////////////////////////////
int CMClientDlg::nCountParameter()
{
    LVITEM            Item;
    int             nCounter;
    int             nNum;
    smIsInputEnum   IsInput;

    nNum        =   m_Parameters.GetItemCount();

    for ( nCounter = 0;  nCounter <= nNum ;nCounter ++)
    {
        assignItem(&Item, LVIF_PARAM,nCounter,0,0,0);
        // if could not get the item from list, return -1
        if (m_Parameters.GetItem(&Item) == 0)
            return -1;
        reinterpret_cast<ISoapMapper *>(Item.lParam)->get_isInput(&IsInput);
        if (IsInput == smOutput)
            nNum --;
    }
    
    return  nNum;
}

///////////////////////////////////////////////