These functions are used for set traversal. Similar to iteration of STL, position is the iterator of MFC, and getstartposition is the first iterator, getnextassoc extracts the current element and moves it backward.
Using this method is the tree control in MFC, And the list control is used to retrieve the next item, which can be used to traverse; in addition, the OLE is used to retrieve the next item in the Document Object. Ctreectrl: getnextitemhtreeitem getnextitem (htreeitem hitem, uint ncode); Return Value: If successful, return the handle of the next item; otherwise, return null. Parameter: handle of a tree item in hitem. Ncode indicates the type of the relationship between hitem and hitem. This flag can be one of the following values: · tvgn_caret gets the selected item. · Tvgn_child gets the first subitem. The hitem parameter must be null. · Tvgn_drophilite is the target item of a drag-and-drop operation. · Tvgn_firstvisible: obtain the first visible item. · Tvgn_next gets the next sibling item. · Tvgn_nextvisible: Obtain the next visual item that follows the specified item. · Tvgn_parent gets the parent item of the specified item. · Tvgn_previous gets the previous sibling item. · Tvgn_previusvisible: obtain the first visible item before the specified item. · Tvgn_root gets the first sub-item of the root item. The specified item is a part of the root item. Note: This member function is used to obtain a tree view item that has a relationship with nitem specified by the ncode parameter. See: ctreectrl: setitem, ctreectrl: getchilditem, ctreectrl: getitem, ctreectrl: selectitem, ctreectrl: getprevsiblingitem
Coledocument class memberColedocument: getnextitemvirtual cdocitem * getnextitem (Position & Pos) const; Return Value: pointer to the document item at the specified position. Parameter: POS is the reference of the position value set by the last call of getnextitem; its initial value is the return value of the member function getstartposition. Note: You can call this function to access every item in your document. After each call, the POs value is set to the position value of the next item in the document. If the obtained element is the last element in the document, the new value of POS is null. Example: // example for coledocument: getnextitem // pdoc points to a coledocument objectposition Pos = pdoc-> getstartposition (); cdocitem * pitem; while (Pos! = NULL) {pitem = pdoc-> getnextitem (POS); // use pitem} see: coledocument: getstartposition, coledocument: getnextclientitem, coledocument: getnextserveritem
Clistctrl class memberClistctrl: getnextitemint getnextitem (INT nitem, int nflags) const returned value: if the result is successful, the next index value is returned; otherwise,-1 is returned. Parameter: Index of the Start item of the nitem search. If it is equal to-1, the specified flag is matched from the first entry. However, the specified item is not included in the search range. The location relationship between the required items and the specified items and the status of the required items. These positional relationships are one of the following values: · lvni_abve searches for an item on the specified item. · Lvni_all searches for subsequent items through the index (which is the default value. · Lvni_below: search for an item under a specified item. · Lvni_toleft: searches for an item on the left of the specified item. · Lvni_toright searches for an item on the right of the specified item. The status can be zero or set to the following values: · lvni_drophilited indicates the entry of the lvis_drophilited status flag. · Lvni_focused sets the lvis_focused status flag. · Lvni_selected sets the lvis_selected status flag. If no status flag is set for the item, the search starts from the next item.
Functions of getstartposition and getnextassoc