Uasually in MFC, i simply use this way,
CXXXView::OnUpdateYYY
to update my toolbar and its status(enable/disable...). It always goes well without any exceptions. But recently, i code a project which uses OpenGL API and MFC, it leads to a different result.
I still do it as usaul in my *.cpp, *.rc. Just like this:
Menuese in .rc:
IDR_COMMANDBAR TOOLBAR 16, 16
BEGIN
BUTTON ID_ACTION_SELECT
BUTTON ID_ACTION_ROTATE
BUTTON ID_ACTION_PAN
SEPARATOR
BUTTON ID_WANDER
BUTTON ID_ANGLE_X_VIEW
BUTTON ID_ANGLE_Y_VIEW
BUTTON ID_ANGLE_Z_VIEW
BUTTON ID_WANDER
END
BEGIN_MESSAGE_MAP(CSeerView, CView)
....
ON_COMMAND(ID_ANGLE_X_VIEW, OnXView)
ON_COMMAND(ID_ANGLE_Y_VIEW, OnYView)
ON_COMMAND(ID_ANGLE_Z_VIEW, OnZView)
ON_COMMAND(ID_ANGLE_FREE_VIEW, OnFreeView)
ON_UPDATE_COMMAND_UI(ID_ANGLE_X_VIEW, OnUpdateXView)
ON_UPDATE_COMMAND_UI(ID_ANGLE_Y_VIEW, OnUpdateYView)
ON_UPDATE_COMMAND_UI(ID_ANGLE_Z_VIEW, OnUpdateZView)
ON_UPDATE_COMMAND_UI(ID_ANGLE_FREE_VIEW, OnUpdateFreeView)
END_MESSAGE_MAP()
All These functions have been archieved in my source code.
The most incredible thing is that some of the command of menues work with updating it corresponding toolbar and some others doesn't work untill i use my mouse to click the CMainFrame'client(Framework Doc-View in MFC) area.
For example, when I click the menu of XView, all menu will be unable except the FreeView toolbar and its menu.
But while I click the menu YView, it doesn't work.
I hope someone can help me.....