Add an item to the tree control in the MDI encountered problems
Time:09-24
Is directly through multiple files vs style code generated by the wizard, hope to open a file at the same time, a number of nodes are added to a view on the left Doc. The relevant code from the CPP Void CMFCApplication1Doc: : OnFileOpen () { HWND HWND=FindWindowEx (NULL, NULL, NULL, _T (" view ")); M_wndClassView1. M_hWnd=HWND; HTREEITEM hRoot=m_wndClassView1. InsertItem (_T (" 123 "), 0, 0). }
Program triggered the breakpoint here {ASSERT (: : IsWindow (m_hWnd)); Return InsertItem (... ), could you tell me where is the problem?
CodePudding user response:
Don't have to write, in the open file function Void CMFCApplication1Doc: : OnFileOpen () { .//open the file and read, do you want to do, of course, if you don't need the file content itself, it also can not read it }
After the complete file open action, all the view will receive a message, it will automatically call views OnInitUpdate () interface (the function name should be this, if not, where is less than), in this function to update their display can