//add item to listbox
afx_msg void CMainFrame::wAddButtonOnClick()
{
CString strText;
wEdit.GetWindowText(strText); if (strText!="")//check textbox is not empty
{
wListBox.AddString(strText);
}
}
//delete selected item from listbox
afx_msg void CMainFrame::wDeleteButtonOnClick()
{ int i = wListBox.GetCurSel(); if (i!=-1)//checks listbox item is selected
{
wListBox.DeleteString(i);
wEdit.SetWindowText("");
}
}
//amend listbox item
afx_msg void CMainFrame::wAmendButtonOnClick()
{
CString strText;
wEdit.GetWindowText(strText); int i = wListBox.GetCurSel(); if (strText!=""&& i!=-1)//checks textbox is not empty
{
wListBox.DeleteString(i);
wListBox.AddString(strText);
}
}
//detects for selected listbox change
afx_msg void CMainFrame::wListBoxChange()
{
CString strText; int i = wListBox.GetCurSel();
wListBox.GetText(i, strText);
wEdit.SetWindowText( strText);//sets textbox to selected listbox item
}