Click here to Skip to main content
15,900,973 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionShowing powers, cubes and squares in a console window Pin
toprogramminguy5-Sep-08 10:11
toprogramminguy5-Sep-08 10:11 
AnswerRe: Showing powers, cubes and squares in a console window Pin
David Crow5-Sep-08 10:21
David Crow5-Sep-08 10:21 
AnswerRe: Showing powers, cubes and squares in a console window Pin
Sauce!7-Sep-08 1:45
Sauce!7-Sep-08 1:45 
QuestionHelp! how to force the control to display the + even though the item does not have any child items inserted Pin
DavidLeeFromKunming5-Sep-08 9:35
DavidLeeFromKunming5-Sep-08 9:35 
QuestionRe: Help! how to force the control to display the + even though the item does not have any child items inserted Pin
David Crow5-Sep-08 10:11
David Crow5-Sep-08 10:11 
AnswerRe: Help! how to force the control to display the + even though the item does not have any child items inserted Pin
DavidLeeFromKunming5-Sep-08 18:06
DavidLeeFromKunming5-Sep-08 18:06 
AnswerRe: Help! how to force the control to display the + even though the item does not have any child items inserted Pin
Mark Salsbery6-Sep-08 8:29
Mark Salsbery6-Sep-08 8:29 
GeneralRe: Help! how to force the control to display the + even though the item does not have any child items inserted Pin
DavidLeeFromKunming6-Sep-08 16:48
DavidLeeFromKunming6-Sep-08 16:48 
Mark Salsbery wrote:
TVN_GETDISPINFO
"Requests that a tree-view control's parent window
provide information needed to display or sort an item."

You shouldn't be inserting items in response to this notification.
You also shouldn't be calling GetSelectedItem().


The TVN_ITEMEXPANDING notification is maybe a better place to insert
the child items.



Thanks a lot,finally i've figure out the problem. Here is my solution

void CMutiTreeCtrl::PopulateTree()
{
    TV_INSERTSTRUCT itInsert = {0};

    CString strText;
    strText = _T("Start");

    itInsert.item.pszText = const_cast<LPTSTR>((LPCTSTR)strText);
    itInsert.item.state = TVIS_BOLD;
    itInsert.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_TEXT |
                            TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
    itInsert.item.stateMask = TVIS_BOLD | TVIS_STATEIMAGEMASK;
    itInsert.item.cChildren = I_CHILDRENCALLBACK;
    itInsert.hParent = hRoot;


    HTREEITEM hItem = this->InsertItem(&itInsert);

    UpdateWindow();
}

void CMutiTreeCtrl::OnTvnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult)
{
    CWaitCursor curWait;
    SetRedraw(FALSE);

    LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
    // TODO: Add your control notification handler code here

    HTREEITEM hItem = pNMTreeView->itemNew.hItem;
    
    // remove all subitems
    HTREEITEM hRemove = this->GetChildItem(hItem);
    while(hRemove)
    {
        ctlTree.DeleteItem(hRemove);
        hRemove = this->GetChildItem(hItem);
    }

    CString strText = _T("This is the Child Item which is dynamiclly inserted");

    AddMySubItems(hItem, strText); // function to insert a child item

    SetRedraw(TRUE);
    Invalidate();

    *pResult = 0;
}

void CMutiTreeCtrl::OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult) 
{
    TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
    // TODO: Add your control notification handler code here
    pTVDispInfo->item.cChildren = 1;
    *pResult = 0;
}


HALLELUJAH! Hallelujah! Hallelujah! Hallelujah!

QuestionMultiple Events Pin
thenutz725-Sep-08 9:26
thenutz725-Sep-08 9:26 
Questiondotted ip address to name? Pin
montiee5-Sep-08 9:06
montiee5-Sep-08 9:06 
QuestionRe: dotted ip address to name? Pin
David Crow5-Sep-08 10:19
David Crow5-Sep-08 10:19 
AnswerRe: dotted ip address to name? Pin
montiee5-Sep-08 10:48
montiee5-Sep-08 10:48 
Questionuse of "SECTION" within a hook dll ..? Pin
only_jack5-Sep-08 8:54
only_jack5-Sep-08 8:54 
QuestionCWnd not receiving PostMessage Pin
gatwork5-Sep-08 8:05
gatwork5-Sep-08 8:05 
Question[Message Deleted] Pin
hhh5-Sep-08 7:54
hhh5-Sep-08 7:54 
AnswerRe: Design Question Pin
Perspx5-Sep-08 10:17
Perspx5-Sep-08 10:17 
GeneralRe: Design Question Pin
hhh5-Sep-08 22:44
hhh5-Sep-08 22:44 
AnswerRe: Design Question Pin
john john mackey5-Sep-08 12:16
john john mackey5-Sep-08 12:16 
GeneralRe: Design Question Pin
hhh5-Sep-08 22:59
hhh5-Sep-08 22:59 
QuestionString literal expansion Pin
Jim Crafton5-Sep-08 7:44
Jim Crafton5-Sep-08 7:44 
AnswerRe: String literal expansion Pin
Michael Dunn5-Sep-08 8:07
sitebuilderMichael Dunn5-Sep-08 8:07 
AnswerRe: String literal expansion Pin
Garth J Lancaster5-Sep-08 15:00
professionalGarth J Lancaster5-Sep-08 15:00 
Questionhow to read data from com port Pin
manju23reddy5-Sep-08 7:40
manju23reddy5-Sep-08 7:40 
QuestionVC++ and CRystalReport Pin
kasi145-Sep-08 7:39
kasi145-Sep-08 7:39 
AnswerRe: VC++ and CRystalReport Pin
liquid_6-Sep-08 10:48
liquid_6-Sep-08 10:48 

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.