|
-
July 28th, 2003, 02:14 AM
#1
Command (Toolbar button) update handler does not get called
Hi,
I've got a command update handler which does the work and update my toolbar button, but... not all the time... !?
Does this handler called every time the application is on idle?
I have a situation where my button should get enabled but the handler doesn't even get called afterwards. Any ideas why?
Is it O.K., in addition to the command update handler, to directly go and update the toolbar button?
Thanks.
-
July 28th, 2003, 02:57 AM
#2
Normally, the toolbar button is related to the menu, so the update handle for menu can change the status of button too,
but you also can add the update handle for tool bar button, and this function, I think, is called each time when the button need to be displayed.
-
July 28th, 2003, 03:00 AM
#3
Can I cause the handler to get called?
-
July 28th, 2003, 03:20 AM
#4
Sorry, something wrong in my previous reply, It should be
When the toolbar need to be displayed and when the condition is changed, the handler function will be called,
for example, if your handler like this:
void CView::OnUpdateEdit(CCmdUI* pCmdUI)
{
UINT m_sel = (UINT) Get();
if (m_sel > 0)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
and then, if m_sel size is changed, the button status will change too.
-
July 28th, 2003, 03:25 AM
#5
Hi,
In my case the condition got changed but the handler doesn't get called after the change - so I would like to force him to get called.
It seems that call the handler directly (which CCmdUi to pass?) is wrong, so how do I make the framework to call it?
-
July 28th, 2003, 04:28 AM
#6
O.K.
My problem got solved, when I moved the command handler and command update handler to the main frame class.
-
July 28th, 2003, 04:31 AM
#7
Hi,
Are you sure that the OnCmdUI() is not called? This is called all the time in my application. Have you tried putting a brkpoint in there (after the app starts running or else you will not be able to interact with it!) ?
I do not think the solution is to explicitly call the handler.
If it really is not called can you show some code?
Extreme situations require extreme measures
-
July 28th, 2003, 04:41 AM
#8
Well,
There is no much to show.
The command update handler is:
void CMainFrame::OnUpdateObjectDelete(CCmdUI* pCmdUI)
{
pCmdUI->Enable( b_existing_object && b_removable_item );
}
-
July 28th, 2003, 05:03 AM
#9
hi Haim B,
you've found the problem by your own: the handlers have to be in the mainframe class anyway, it doesn't work properly in any other class ( like CView and for sure not in a CDocument )
greetings and blue skies
-
July 28th, 2003, 05:11 AM
#10
Hi, Tomcat101:
I do have some projects which has handler in CView and CDoc.
So I can't agree what you said.
-
July 28th, 2003, 06:32 AM
#11
hi,
yes, i know that they're working in this classes too, but for me it makes no sense because normally ( in every project that i made till now ) the toolbar is part of the mainframe and when i need to update them i make this in relation to the current used CDoc or CView.
the second reason why i make my updates in the mainframe is that the handler of the standard-buttons like 'NewFile', 'OpenFile' and so on are in the mainframe-class too and i like to have them on one place, so if i have to make changes i know where to search;
but for sure you're right that it is functional in all this classes, too.
greetings and blue skies
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|