Home > Software engineering >  VC 2012 click the node tree controls TreeCtrl, how to create a new view?
VC 2012 click the node tree controls TreeCtrl, how to create a new view?

Time:09-27


1, using vc + + MFC application wizard to create more document 2012 "MRMS
"

2, add a new document, view and framework (ImportGradeCtrl), and on the function of "import data" (MRMS. CPP) menu to create a new document:
 void CMRMSApp: : OnImpGc () 
{
//TODO: add the command handler code
The POSITION curTemplatePos=GetFirstDocTemplatePosition ();
Int iii=0;
While (curTemplatePos!=NULL)
{
CDocTemplate * curTemplate=
GetNextDocTemplate (curTemplatePos);
Cstrings STR.
CurTemplate - & gt; GetDocString (STR, CDocTemplate: : docName);

If (STR==_T (" ImportGradeControl "))
{
CurTemplate - & gt; OpenDocumentFile (NULL);
return;
}
}
}



3, the following to the click "file view" window of the tree node " create a new document view , how to do?




The following code is the tree view on the response function of the mouse click
 void CViewTree: : OnNMClick (NMHDR * pNMHDR, LRESULT * pResult) 
{
//for the currently selected item
CTreeCtrl * pTreeCtrl=this;
CPoint ptCurSel (0, 0);
TVHITTESTINFO HitTestInfo;

//by the mouse position in the client area
The GetCursorPos (& amp; PtCurSel);
PTreeCtrl - & gt; The ScreenToClient (& amp; PtCurSel);

//which one is selected for current
HitTestInfo. Pt=ptCurSel;
HTREEITEM hSelect=pTreeCtrl - & gt; HitTest (& amp; HitTestInfo);
Cstrings strItem;
If (hSelect!=NULL)
{
StrItem=pTreeCtrl - & gt; GetItemText (hSelect);
: : AfxMessageBox (strItem);
}
//set the state for the selected
PTreeCtrl - & gt; SelectItem (hSelect);

If (strItem==_T (" grade control database "))
{

//if you click on the node is "grade database" is here to create a new view
//the view has been created, can be in the menu click on the create

?????
?????


}

}


Please expert advice, thank you!

CodePudding user response:

Create a document window with can call CWinAppEx: : OnFileNew ();

CodePudding user response:

I want to by the click the node tree view, according to the different labels of node , the creation of a new view of the different, is want to CViewTree: : OnNMClick (NMHDR * pNMHDR, LRESULT * pResult) this function to create the new view (I have already realized the discriminant of the node labels in the function)

CodePudding user response:

Also send 2 times...

CodePudding user response:

AfxGetMainWnd () - & gt; PostMessage (,,, ID_FILE_NEW);
  • Related