Problem in using toolbar.
Hi all,
i have SDI type application,and split it in two columns.
for one column i m using a Treeview and for another one i m using a FormView.
in toolbar two buttons functions override in Treeview class because they are related to treeview here i m inserting,deleting the tree items.
when i focus on formview and than click on those toolbar buttons than they are not working ,while when i have focus on TreeView and than click on those buttons than those are working perfectly.
please tell me how can i use as general.
if possible please explain me with example.
thanks in advance.
Re: Problem in using toolbar.
1. Define "not working".
2. Where (in what class) are the message handlers for all these buttons that are "not working"?
Re: Problem in using toolbar.
Quote:
in toolbar two buttons functions override in Treeview class because they are related to treeview here i m inserting,deleting the tree items.
What is that suppose to mean? That you have handlers for the button commands in the tree view class?
When you say "not working" you mean they are not called, or that they don't do what you expected?
Re: Problem in using toolbar.
I mean to say,in my toolbar i have 5 buttons,where out of five i have add message handler of two buttons in Treeview class.
because these buttons used for inserting items in tree or deleteing items of tree.
When i have focus on Formview and than click on these two buttons than these not called.
so please tell me what can i do.
Re: Problem in using toolbar.
I wonder why do you ever "click on these two buttons" being in FormView while "these buttons used for inserting items in tree or deleteing items of tree" and therefore you "have add message handler of two buttons in Treeview class"
The FormView should nothnig know about any other view, so your design with toolbar buttons message handler is correct: while FormView is active they have to be either disabled or hidden.
Re: Problem in using toolbar.
What he means is that only certain button are active depending on what view was last selected.
I had the same problem when creating split views.
What you need to do is call the buttons from the CMainFrame and then execute the functions in the appropriate view classes. You will need to have pointers to the view classes.
Re: Problem in using toolbar.
In those functions i m using thread that is used in Treeview class and i dont knoe how can i use it from class pointer in mainframe.
Re: Problem in using toolbar.
Quote:
Originally Posted by
vjshankwar
In those functions i m using thread that is used in Treeview class and i dont knoe how can i use it from class pointer in mainframe.
Code:
if(!this->m_wndSplitter.CreateStatic(this,1,2)){
return FALSE;
};
if(!this->m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftFormView),CSize(350,100), pContext)||
!this->m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CMfcieView),CSize(100,100),pContext))
{
this->m_wndSplitter.DestroyWindow();
return FALSE;
}
//return CFrameWnd::OnCreateClient(lpcs, pContext);
//Setup Pointers
this->m_pHTMLView = (CMfcieView*)m_wndSplitter.GetPane(0,1);
this->m_pCLeftFormView = (CLeftFormView*)m_wndSplitter.GetPane(0,0);
return TRUE;
I copied the code from my app, but you should have the idea.
Create two member pointer variables to the view classes in CMainFrame.
Now from CMainFrame you should be able to call any member functions of either View Classes and the buttons will always be active.
I could be wrong, but I believe you can even set the active view.
Re: Problem in using toolbar.
Since you have an SDI application, you can put the message handler for the button in the doc class. Then there are a couple of alternatives... if you want to handle everthing in the doc (not the best idea perhaps), you may need to get pointer to the views (see GetFirstViewPostion, etc).
Alternatively, you could call UpdateAllViews from within the doc class. This calls OnUpdate in each view, and in the view's OnUpdate handler, do whatever is needed. This is the "MFC" way of doing things.
You might check out "Command Routing in MFC" from MSDN.
Hope that helps.