Toolbars and MDI Apps
-
Alright All, I have a small brain teaser to do with Toolbars. I have managed to setup a toolbar successfully in the CMainFrame section of MDI App. Every time I open a file / create a new file it adds the relevant information to the combo box (i.e. the name of the file). Its then possible that I do some operations on these files, the names of these operations are then also recorded IN ORDER in the combo box. However, since I have an MDI app, and I`ve used the CMainFrame section to house the combo box, it is possible that the user mixes up the entries in the combo box that are associated with the different windows. I would like to be able to keep them separate, so that when the user clicks on a particular window, the combo box reflects the changes I`ve made to that one and that one only (and if I re-activated the other window it would re-display all the changes to that one etc.). I would appreciate any advice on this, even if it was to just tell me where to store the combo box control or how to switch back and forth different combo boxes as the different windows are activated. Cheers again guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:
-
Alright All, I have a small brain teaser to do with Toolbars. I have managed to setup a toolbar successfully in the CMainFrame section of MDI App. Every time I open a file / create a new file it adds the relevant information to the combo box (i.e. the name of the file). Its then possible that I do some operations on these files, the names of these operations are then also recorded IN ORDER in the combo box. However, since I have an MDI app, and I`ve used the CMainFrame section to house the combo box, it is possible that the user mixes up the entries in the combo box that are associated with the different windows. I would like to be able to keep them separate, so that when the user clicks on a particular window, the combo box reflects the changes I`ve made to that one and that one only (and if I re-activated the other window it would re-display all the changes to that one etc.). I would appreciate any advice on this, even if it was to just tell me where to store the combo box control or how to switch back and forth different combo boxes as the different windows are activated. Cheers again guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:
I would recommend keeping the list of changes you have made in the document object. Then wehn tyhe user switches document, (or toa different view), you can handle the OnSetActive of that view and populate the combo box in the toolbar. Something like:
void CMyView::OnSetActive(bool m_bActivate)
{
if (m_bActivate)
{
CComboBox* pCombo = &((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_ComboBox ; // get pointer to combo from mainframe object
pCombo->ResetContent() ;
// add the items here...
}
}Its a bit rough and done from memory so it may be a little bit buggy:-D Roger Allen Sonork 100.10016
-
I would recommend keeping the list of changes you have made in the document object. Then wehn tyhe user switches document, (or toa different view), you can handle the OnSetActive of that view and populate the combo box in the toolbar. Something like:
void CMyView::OnSetActive(bool m_bActivate)
{
if (m_bActivate)
{
CComboBox* pCombo = &((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_ComboBox ; // get pointer to combo from mainframe object
pCombo->ResetContent() ;
// add the items here...
}
}Its a bit rough and done from memory so it may be a little bit buggy:-D Roger Allen Sonork 100.10016
After I had written the question, for some unknown reason (I`ll call it fate), this exact same solution came into my head. I was, in fact just about to delete this thread thinking that no-one would respond so quickly, amazing. I would, however, like to thank you for responding and re-affirming this solution, because it came from nowhere in my head, and I always tend to think "is this the best solution - mmmm I dunno", but since your response I have no fear. Thanks Roger, very much appreciated, Alan.:-D P.S. your solution seems pretty damn good, if thats "a bit rough" I feel quite inadequate :-D. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad: