// 【建议】直接在播放列表里嵌入一个listbox控件来存放文件路径,这样操作起来就方便多了。
// 由于没有Demo可以参考,所以为了让大家知道treeview的更多用法,这里用treeview作为示例。
void CDuiFrameWnd::GetPlaylistInfo(int &iIndexTreeStart, int &iFileCount)
{
    iIndexTreeStart = -1;
    iFileCount      = 0;

    // 查找路径文件的起始节点,目前为nodePlaylist第3个子节点
    CTreeNodeUI *pNodeTmp; 
    CTreeNodeUI *pNodePlaylist = static_cast<CTreeNodeUI*>(m_PaintManager.FindControl(_T("nodePlaylist")));
    int iNodeTotal = pNodePlaylist->GetCountChild();
    int i;

    for(i = 0; i < iNodeTotal; i++)
    {
        pNodeTmp = pNodePlaylist->GetChildNode(i);

        if (U_TAG_PLAYLIST == pNodeTmp->GetTag())
        {
            break;
        }
    }

    // 未找到U_TAG_PLAYLIST的子节点,说明没有文件加入
    if (i == iNodeTotal)
    {      
        return;
    }

    // 已找到起始节点,开始找上一个文件或下一个文件
    CTreeViewUI* pTree = static_cast<CTreeViewUI*>(m_PaintManager.FindControl(_T("treePlaylist")));
    if (pTree)
    {
        iIndexTreeStart = pTree->GetItemIndex(pNodeTmp); 
        iFileCount      = iNodeTotal - i;
    }
}
Exemple #2
0
	IMPL_LUA_FUNC(LuaCTreeNodeUI, GetChildNode)
	{
		try
		{
			CTreeNodeUI* self;
			self = static_cast<CTreeNodeUI*>(LuaStatic::CheckUserData(l, 1));
			int iIndex = lua_tointeger(l,2);
			CTreeNodeUI* pTreeNodeUI = self->GetChildNode(iIndex);
			if (pTreeNodeUI)
				LuaStatic::AddObject2Lua(l, pTreeNodeUI, METATABLE_NAME(pTreeNodeUI));
			else
				lua_pushnil(l);
			return 1;
		}
		catch (...)
		{
			DuiException(_T("LuaCTreeNodeUI::GetChildNode"));
			return 0;
		}
	}