Click here to Skip to main content
15,912,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CCtrlView does not show my items Pin
Ben Burnett31-Jul-01 14:24
Ben Burnett31-Jul-01 14:24 
GeneralRe: CCtrlView does not show my items Pin
Wim Jans1-Aug-01 2:12
Wim Jans1-Aug-01 2:12 
GeneralExtracting features from a BMP Pin
Russel Hawkins31-Jul-01 10:57
Russel Hawkins31-Jul-01 10:57 
GeneralRe: Extracting features from a BMP Pin
Chris Losinger31-Jul-01 11:18
professionalChris Losinger31-Jul-01 11:18 
GeneralRe: Extracting features from a BMP Pin
Russel Hawkins31-Jul-01 21:36
Russel Hawkins31-Jul-01 21:36 
GeneralReading int/long lengths from binary file Pin
31-Jul-01 10:08
suss31-Jul-01 10:08 
GeneralRe: Reading int/long lengths from binary file Pin
Paolo Messina31-Jul-01 10:45
professionalPaolo Messina31-Jul-01 10:45 
GeneralIEnumIDList and Next usage Pin
31-Jul-01 9:34
suss31-Jul-01 9:34 
Hi all,

When I use the code below to enumerate the shell namespace, a second thread seems to get started by the IEnumIDList::Next(...) function. This function executes normally and gives me the desired results, but for some reason when my program exits, the second thread (not the application thread) always terminates with a return code of -1 and not 0 (like the main thread). This second thread delays the termination of my program quite considerably and is rather annoying. It would seem to suggest that I'm not using IEnumIDList properly, because if I take out the while(...) loop with the ::Next(...) call in it, the second thread never appears. So, my question is, what is wrong with the following call? What am I not doing to stop this second thread that appears out of nowhere?? Confused | :confused:


------ CODE -------
void CFileTreeView::OnInitialUpdate()
{
HTREEITEM rNode;
ITEMIDLIST *pidl;
IShellFolder *pShellRoot;
DWORD iGot;

// Called inherited constructor.
CTreeView::OnInitialUpdate();

// Clear the view.
GetTreeCtrl().DeleteAllItems();

// Get a pointer to the IShellFolder namespace.
pShellRoot = GetDocument()->GetShellRoot();

// Iterate through the shell namespace for devices.
if(SHGetSpecialFolderLocation(m_hWnd, CSIDL_DESKTOP, &pidl) == NO_ERROR)
{
rNode = AddNode( pShellRoot, pidl, pidl );

IEnumIDList *pidlList;
if(pShellRoot->EnumObjects(m_hWnd, SHCONTF_FOLDERS |
SHCONTF_INCLUDEHIDDEN, &pidlList) == NO_ERROR)
{
while( pidlList->Next(1, &pidl, &iGot) == NO_ERROR )
AddNode( pShellRoot, pidl, pidl, rNode );

pidlList->Release();
}

GetTreeCtrl().Expand( rNode, TVE_EXPAND );
}
else AfxMessageBox("SHGetSpecialFolderLocation() failed! No namespace!");

GetDocument()->ReleaseShellRoot();
}

The AddNode(...) function simply fills out a TV_ITEM structure and creates a node, I am aware that the pidl's from the IEnumIDList(...) are not freed, they are dealt with in an OnDelete() handler for the individual tree nodes.
GetShellRoot() and ReleaseShellRoot() simply wrap the AddRef() and Release() functions for IShellFolder and display TRACE messages if I forget to release an instance.

Any help would be appreciated.
Jonathan Thorpe
GeneralResizing List Control Columns Pin
Scott Evans31-Jul-01 9:13
Scott Evans31-Jul-01 9:13 
GeneralRe: Resizing List Control Columns Pin
Tomasz Sowinski31-Jul-01 9:21
Tomasz Sowinski31-Jul-01 9:21 
GeneralRe: Resizing List Control Columns Pin
Paolo Messina31-Jul-01 10:33
professionalPaolo Messina31-Jul-01 10:33 
GeneralSetting font used by TextOut Pin
31-Jul-01 7:18
suss31-Jul-01 7:18 
GeneralRe: Setting font used by TextOut Pin
Tomasz Sowinski31-Jul-01 7:39
Tomasz Sowinski31-Jul-01 7:39 
GeneralDISPLAY AMOUNTS WITH COMMAS Pin
31-Jul-01 7:02
suss31-Jul-01 7:02 
GeneralRe: DISPLAY AMOUNTS WITH COMMAS Pin
Ben Burnett31-Jul-01 14:36
Ben Burnett31-Jul-01 14:36 
GeneralRe: DISPLAY AMOUNTS WITH COMMAS Pin
Bret Faller3-Aug-01 10:02
Bret Faller3-Aug-01 10:02 
Generalchange text color in a combo box Pin
31-Jul-01 6:34
suss31-Jul-01 6:34 
GeneralProblem with Cristi Posea's CSizingControlBar Pin
Jamie Nordmeyer31-Jul-01 6:20
Jamie Nordmeyer31-Jul-01 6:20 
GeneralCFtpFileFind Pin
31-Jul-01 6:13
suss31-Jul-01 6:13 
Generalset text color of a combo box Pin
31-Jul-01 5:50
suss31-Jul-01 5:50 
GeneralSending Messages Pin
31-Jul-01 5:05
suss31-Jul-01 5:05 
GeneralRe: Sending Messages Pin
Tomasz Sowinski31-Jul-01 9:16
Tomasz Sowinski31-Jul-01 9:16 
GeneralRe: Sending Messages Pin
31-Jul-01 12:03
suss31-Jul-01 12:03 
GeneralActiveX CView and OpneGL Pin
31-Jul-01 4:52
suss31-Jul-01 4:52 
GeneralRe: ActiveX CView and OpneGL Pin
Not Active31-Jul-01 15:35
mentorNot Active31-Jul-01 15:35 

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.