Hello guys,
I wanted to make a tree control, and I have done that.
Then I wanted to put a button and each time the user clicks the button I wanted it to put a root on the tree with a default name. I have done that also.
Now, I want to put an edit box, which I have done already.
1. I want to read what the user types in the edit box
2. When the user clicks my button that I created earlier, I want the root name to be what the user typed.
Note: I have created an SDI application and on that I have created each control by code.
Here is part of my code:
This is where I am actually creating the Tree, Edit, and Button Controls
This where I am creating the roots for the tree
I am having trouble reading the editbox and use that as the name of the root.
If any one of you could help me in anyway, I really appreciate it. Thank you so much.
Sunny
I wanted to make a tree control, and I have done that.
Then I wanted to put a button and each time the user clicks the button I wanted it to put a root on the tree with a default name. I have done that also.
Now, I want to put an edit box, which I have done already.
1. I want to read what the user types in the edit box
2. When the user clicks my button that I created earlier, I want the root name to be what the user typed.
Note: I have created an SDI application and on that I have created each control by code.
Here is part of my code:
This is where I am actually creating the Tree, Edit, and Button Controls
Code:
// This creates the Tree View
void CTreeTwoView::CreateTreeView(void)
{
// Create the Image List
m_treeImageList.Create(13, 13, FALSE, 3, 0);
HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
m_treeImageList.Add(hIcon);
// Create the Tree View Control
m_treeView.Create(WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES | TVS_LINESATROOT |
TVS_HASBUTTONS | TVS_EDITLABELS, CRect(20, 260, 160, 360), this, IDC_TREEVIEW);
// Associates the image list with the list view
m_treeView.SetImageList(&m_treeImageList, TVSIL_NORMAL);
// Create the Control Buttons
m_addRoute.Create("Add Route", WS_VISIBLE | WS_CHILD | WS_BORDER, CRect(170, 260, 250, 280),
this, IDC_ADDROUTE);
// Create the Edit Box to enter the name of the Route
m_routeName.Create(WS_VISIBLE | WS_CHILD | WS_BORDER, CRect(170, 290, 250, 310),
this, IDC_ROUTENAME);
}
This where I am creating the roots for the tree
Code:
void CTreeTwoView::OnAddRoute()
{
/*CString rString;*/
/* m_routeName.GetWindowText(rString, 5);*/
TVITEM tvItem;
tvItem.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvItem.pszText = "Route";
//tvItem.pszText = m_routeName.m_edit;
tvItem.cchTextMax = 5;
tvItem.iImage = 0;
tvItem.iSelectedImage = 0;
TVINSERTSTRUCT tvInsert;
tvInsert.hParent = TVI_ROOT;
tvInsert.hInsertAfter = TVI_FIRST;
tvInsert.item = tvItem;
HTREEITEM hRoot = m_treeView.InsertItem(&tvInsert);
}
I am having trouble reading the editbox and use that as the name of the root.
If any one of you could help me in anyway, I really appreciate it. Thank you so much.
Sunny