?? get_next.shtml
字號:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Zafir Anjum">
<META NAME="GENERATOR" CONTENT="Mozilla/4.0 [en] (WinNT; I) [Netscape]">
<TITLE>Get next item in outline</TITLE>
</HEAD>
<body background="../fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000" bgproperties="fixed">
<table WIDTH="100%">
<tr WIDTH="100%">
<td align=center><!--#exec cgi="/cgi/ads.cgi"--><td>
</tr>
</table>
<CENTER>
<H3>
<FONT COLOR="#AOAO99">Get next item in outline</FONT></H3></CENTER>
<CENTER>
<H3>
<HR></H3></CENTER>
Imagine that the outline is completely expanded. Pressing the down key
will take you down on line to the next item. Now imagine that instead of
expanding the outline and pressing the down key, you want to get to the
items in the same sequence programmatically. Although the CTreeView control
provides a GetNextItem() function, it does not provide direct support for
our needs. Listed below is an overloaded version of GetNextItem() taking
a single argument. Before we actually look at the function lets first look
at the declaration of the function in the CTreeView derived class.
<BR>
<PRE><TT><FONT COLOR="#990000"> HTREEITEM GetNextItem( HTREEITEM hItem, UINT nCode ){
return CTreeCtrl::GetNextItem( hItem, nCode );
}
HTREEITEM GetNextItem( HTREEITEM hItem);</FONT></TT></PRE>
It is important that we override the original function taking two arguments
otherwise our new version of the function will hide it. Now here is the
listing of the overloaded GetNextItem() function.
<BR>
<PRE><TT><FONT COLOR="#990000">// GetNextItem - Get next item as if outline was completely expanded
// Returns - The item immediately below the reference item
// hItem - The reference item
HTREEITEM CTreeCtrlX::GetNextItem( HTREEITEM hItem )
{
HTREEITEM hti;
if( ItemHasChildren( hItem ) )
return GetChildItem( hItem ); // return first child
else{
// return next sibling item
// Go up the tree to find a parent's sibling if needed.
while( (hti = GetNextSiblingItem( hItem )) == NULL ){
if( (hItem = GetParentItem( hItem ) ) == NULL )
return NULL;
}
}
return hti;
}</FONT></TT>
</PRE>
<P>
<HR>
<TABLE BORDER=0 WIDTH="100%" >
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="http://www.codeguru.com">Goto HomePage</A></FONT></TD>
<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>© 1998 Zafir Anjum</FONT> </CENTER>
</TD>
<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A> </FONT></DIV>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -