Click here to Skip to main content
15,920,503 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Adding Sound to AVI Files Pin
normanS13-Jun-05 20:54
normanS13-Jun-05 20:54 
Generalcustomize key bindings / accelerators Pin
ehh13-Jun-05 8:10
ehh13-Jun-05 8:10 
GeneralRe: customize key bindings / accelerators Pin
Blake Miller13-Jun-05 8:50
Blake Miller13-Jun-05 8:50 
GeneralRe: customize key bindings / accelerators Pin
ehh14-Jun-05 3:55
ehh14-Jun-05 3:55 
GeneralRe: customize key bindings / accelerators Pin
Blake Miller14-Jun-05 5:01
Blake Miller14-Jun-05 5:01 
GeneralRe: customize key bindings / accelerators Pin
ehh14-Jun-05 6:30
ehh14-Jun-05 6:30 
GeneralActiveX Ctrl hanging in MFC code: _AfxFindNextMnem Pin
Ian Bowler13-Jun-05 8:09
Ian Bowler13-Jun-05 8:09 
GeneralExpanding Trees Pin
victorsk13-Jun-05 7:56
victorsk13-Jun-05 7:56 
Hello,

I have a question about expanding CTreeCtrl items. What I first do is populate a tree like this:

void CMain:oDrive(const CString& str)
{
local = true;
m_tmain.DeleteAllItems();
CString cstr = _T(str);
TV_INSERTSTRUCT root = {0};
::ZeroMemory(&root, sizeof(TV_INSERTSTRUCT));
root.hParent = NULL;
root.hInsertAfter = TVI_LAST;
root.item.iImage = 1;
root.item.iSelectedImage = 1;
root.item.pszText = (LPTSTR)(LPCTSTR)cstr;
root.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
HTREEITEM root_item = m_tmain.InsertItem(&root);
TV_INSERTSTRUCT tvstruct;
CFileFind find;
BOOL bDir = FALSE;
bool cDir = false;
BOOL bContinue = find.FindFile(cstr + _T("\\") + _T("*.*"), 0);
tvstruct.hParent = root_item;
CString strFileName;
while (bContinue)
{
bContinue = find.FindNextFile();
strFileName = find.GetFileName();

if (find.IsDirectory())
{
bDir = TRUE;
cDir = true;
tvstruct.hParent = NULL;
tvstruct.item.iImage = 0;
tvstruct.item.iSelectedImage = 0;
tvstruct.item.pszText = (LPTSTR)(LPCTSTR)strFileName;
tvstruct.hInsertAfter = TVI_LAST;
tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
HTREEITEM hThisItem = m_tmain.InsertItem(&tvstruct);
tvstruct.hParent = hThisItem;
m_tmain.InsertItem(&tvstruct);
}
else
{
tvstruct.item.iImage = 2;
tvstruct.item.iSelectedImage = 2;
tvstruct.hParent = NULL;
tvstruct.item.pszText = (LPTSTR)(LPCTSTR)strFileName;
tvstruct.hInsertAfter = TVI_LAST;
tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
m_tmain.InsertItem(&tvstruct);
}
}
find.Close();
}

This works fine and the tree gets populated with right items. However, when I try to expand a directory by clicking on a + Nothing happens. What I first trying to do is just get a directory name. This is my function that is trying to get a directory name:

void CMain::OnTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM hIT = pNMTreeView->itemNew.hItem;
CString path;
if (pNMTreeView->hdr.code == TVN_ITEMEXPANDING)
{MessageBox("Expanding");}
path = m_tmain.GetItemText(hIT);
while (true)
{
hIT = m_tmain.GetParentItem(hIT);
if (hIT == NULL)
break;
path = m_tmain.GetItemText(hIT) + _T("\\") + path;
}
path += _T("\\*.*");
MessageBox(path);
*pResult = 0;
}

The MessageBox only shows *.* and I can't get a directory name from m_tmain.GetItemText(hIT). Does anybody know what the problem is here? It is necessary to get a directory name to pass that variable to ExploreDirectory(CString some_directory) function. Please help.

Thank you,
Victor.

Generaltoupper macro key Pin
Stober13-Jun-05 6:56
Stober13-Jun-05 6:56 
GeneralRe: toupper macro key Pin
Chris Losinger13-Jun-05 7:06
professionalChris Losinger13-Jun-05 7:06 
GeneralRe: toupper macro key Pin
Stober13-Jun-05 7:24
Stober13-Jun-05 7:24 
GeneralRe: toupper macro key Pin
Chris Losinger13-Jun-05 7:26
professionalChris Losinger13-Jun-05 7:26 
GeneralRe: toupper macro key Pin
Stober13-Jun-05 8:57
Stober13-Jun-05 8:57 
GeneralVery basic question Pin
Opa Knack13-Jun-05 6:49
Opa Knack13-Jun-05 6:49 
GeneralRe: Very basic question Pin
Maximilien13-Jun-05 7:13
Maximilien13-Jun-05 7:13 
GeneralRe: Very basic question Pin
Budric B.13-Jun-05 7:16
Budric B.13-Jun-05 7:16 
GeneralRe: Very basic question Pin
Opa Knack13-Jun-05 7:28
Opa Knack13-Jun-05 7:28 
GeneralRe: Very basic question Pin
Cedric Moonen13-Jun-05 7:37
Cedric Moonen13-Jun-05 7:37 
GeneralRe: Very basic question Pin
Opa Knack13-Jun-05 7:45
Opa Knack13-Jun-05 7:45 
GeneralRe: Very basic question Pin
Cedric Moonen13-Jun-05 8:03
Cedric Moonen13-Jun-05 8:03 
GeneralRe: Very basic question Pin
David Crow13-Jun-05 7:00
David Crow13-Jun-05 7:00 
GeneralRe: Very basic question Pin
Opa Knack13-Jun-05 10:04
Opa Knack13-Jun-05 10:04 
GeneralRe: Very basic question Pin
David Crow13-Jun-05 8:30
David Crow13-Jun-05 8:30 
QuestionHow do I remove the WS_THICKFRAME style? Pin
Anonymous13-Jun-05 6:12
Anonymous13-Jun-05 6:12 
AnswerRe: How do I remove the WS_THICKFRAME style? Pin
David Crow13-Jun-05 6:17
David Crow13-Jun-05 6:17 

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.