Click here to Skip to main content
15,911,711 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Why I can't get record from database Pin
Joel Lucsy19-Nov-01 3:04
Joel Lucsy19-Nov-01 3:04 
GeneralMFC and DLL... Pin
19-Nov-01 0:45
suss19-Nov-01 0:45 
GeneralRe: MFC and DLL... Pin
Cathy19-Nov-01 11:58
Cathy19-Nov-01 11:58 
GeneralAnti-Alias Pin
19-Nov-01 0:41
suss19-Nov-01 0:41 
GeneralRe: Anti-Alias Pin
Rui Lopes19-Nov-01 4:23
Rui Lopes19-Nov-01 4:23 
GeneralCTreeCtrl Pin
19-Nov-01 0:37
suss19-Nov-01 0:37 
GeneralRe: CTreeCtrl Pin
Joel Lucsy19-Nov-01 3:09
Joel Lucsy19-Nov-01 3:09 
GeneralRe: CTreeCtrl Pin
Shog920-Nov-01 12:22
sitebuilderShog920-Nov-01 12:22 
This will work nicely (apart from the typos Wink | ;) ):
// assumtions:  	this is a message handler for TVN_ITEMEXPANDING
// 		there is a member variable named m_wndTree which is the tree
//			there is an image list with the first image being a closed folder,
//		and the second an open folder
//
void CWindowWithTreeCtrlInIt::OnTreeItemExpanding( NMHDR* pNMHDR, LRESULT* pResult)
{
	*pResult = 0;	// it's all good

	// get some useful information
	NMTREEVIEW* pNMTreeView = (NMTREEVIEW*)pNMHDR;
	HTREEITEM hCurrent = pNMTreeView->itemNew.hItem;

	// *current* state of the item; it will be the reverse of this after expansion
	BOOL bExpanded = TVIS_EXPANDED & m_wndTree.GetItemState(hCurrent, TVIS_EXPANDED);
	
	// toggle icon, if it has children (why would it be expanding otherwise?)
	if ( m_wndTree.ItemHasChildren(hCurrent) )
	{
		int nNewImage = bExpanded ? 0 : 1;	// 0 == collapsed image, 1 == expanded image
		m_wndTree.SetItemImage(hCurrent, nImage, nImage);
	}
}

Important bits: use TVN_ITEMEXPANDING, not TVN_ITEMEXPANDED; TVN_ITEMEXPANDED is only called the first time an item is expanded, or after TVE_COLLAPSERESET has been called on it.
GeneralODBC OS Specific error Pin
Deian19-Nov-01 0:34
Deian19-Nov-01 0:34 
GeneralRe: ODBC OS Specific error Pin
Alvaro Mendez19-Nov-01 10:54
Alvaro Mendez19-Nov-01 10:54 
GeneralRe: ODBC OS Specific error Pin
Deian19-Nov-01 23:04
Deian19-Nov-01 23:04 
Generalmemory leaks Pin
luckylourson18-Nov-01 23:22
luckylourson18-Nov-01 23:22 
GeneralRe: memory leaks Pin
Bernhard19-Nov-01 3:08
Bernhard19-Nov-01 3:08 
GeneralRe: memory leaks Pin
Alvaro Mendez19-Nov-01 11:09
Alvaro Mendez19-Nov-01 11:09 
GeneralRe: memory leaks Pin
Derek Waters19-Nov-01 14:13
Derek Waters19-Nov-01 14:13 
GeneralRe: memory leaks Pin
Bernhard19-Nov-01 19:21
Bernhard19-Nov-01 19:21 
Generalthanx Pin
luckylourson19-Nov-01 23:14
luckylourson19-Nov-01 23:14 
GeneralRe: thanx Pin
Bernhard19-Nov-01 23:24
Bernhard19-Nov-01 23:24 
GeneralRe: memory leaks Pin
Alvaro Mendez20-Nov-01 8:22
Alvaro Mendez20-Nov-01 8:22 
GeneralRe: memory leaks Pin
Rassman20-Nov-01 5:56
Rassman20-Nov-01 5:56 
GeneralEmbedded ActiveX control Pin
RaviRao18-Nov-01 22:20
RaviRao18-Nov-01 22:20 
GeneralRe: Embedded ActiveX control Pin
Rassman19-Nov-01 2:50
Rassman19-Nov-01 2:50 
GeneralAdding Hot spot to help ! Pin
Hadi Rezaee18-Nov-01 20:29
Hadi Rezaee18-Nov-01 20:29 
GeneralRe: Adding Hot spot to help ! Pin
Roger Allen19-Nov-01 5:26
Roger Allen19-Nov-01 5:26 
GeneralRe: Adding Hot spot to help ! Pin
Hadi Rezaee19-Nov-01 7:59
Hadi Rezaee19-Nov-01 7:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.