All pastes #231387 Raw Edit

Anonymous

public text v1 · immutable
#231387 ·published 2006-10-31 20:12 UTC
rendered paste body
HTREEITEM CawnnDlg::GetNthItem(int n)
{
        return __GetNthItem(n, m_tree.GetRootItem());
}

HTREEITEM CawknnDlg::__GetNthItem(int &step, HTREEITEM hdl)
{
	CString x = m_tree.GetItemText(hdl);
	if (--step <= 0)
		return hdl;

	HTREEITEM child = m_tree.GetNextItem(hdl, TVGN_CHILD);
	if (child != NULL) {
		HTREEITEM r = __GetNthItem(step, child);
		if (r != NULL && step <= 0)
			return r;
	}

	HTREEITEM sibling = m_tree.GetNextSiblingItem(hdl);
	if (sibling != NULL) {
		HTREEITEM r = __GetNthItem(step, sibling);
		if (r != NULL && step <= 0)
			return r;
	}

	return NULL;
}