Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Custom Toolbars Collapse All
Subject Author Date
David Skok Dec 13, 2006 - 12:45 PM

I notice in DrawCLI sample toolbar resources are used to associate commands with Icons in CExtCommandManager then in code custom toolbars are created. I prefer to use this method exclusively as it is easier to create one or more large toolbar resources with commands and Icons then as I develop code I can easily change toolbar content and button order without editing bitmaps etc. Later on I can customize at runtime.

I have run into a problem. The custom toolbar names are included in the in the "Show or Hide Panels" toolbar drop down which is ok. I include the following code in the mainframe message map so that the menu items are active and work.

    ON_COMMAND_EX(ID_CUSTOM_TOOLBAR, OnBarCheck )
    ON_UPDATE_COMMAND_UI(ID_CUSTOM_TOOLBAR, OnUpdateControlBarMenu)

I do NOT include the toolbar commands in any of my menus and as such they are not registered in Command manager. I may or may not in the future.

Assuming state info does not initially exist...
the problem comes up when I start the app, close one of the buton bars, close the application then restart it. On restart I get an assert that the command for the toolbar show/hide is not present then the next instruction throws an exception. This occurs in:

bool CExtCmdProfile::SerializeState(
    CArchive & ar,
    bool bEnableThrowExceptions // = false
    )
...
...
........
            for( ; true; )
            {
                UINT nCmdId, nUsageTickCount;
                ar >> dwTmp;
                nCmdId = UINT(dwTmp);
                if( nCmdId == 0 )
                    break;
                ar >> dwTmp;
                nUsageTickCount = UINT(dwTmp);
                CExtCmdItem * pCmdItem = CmdGetPtr(nCmdId);
-->ASSERT here ASSERT( pCmdItem != NULL );
-->exception here trying to use NULL pCmdItem
ASSERT( !(pCmdItem->StateIsBasic()) );
                ASSERT( !(pCmdItem->StateIsForceRarely()) );
                ASSERT( !(CExtCmdManager::IsSystemCommand(pCmdItem->m_nCmdID)) );
                pCmdItem->m_nUsageTickCount = nUsageTickCount;
            }

May I suggest for robustness sake that you change the code so that if pCmdItem is null maybe still throw an assert but "continue;" from there so that NULL pCmdItem is not used and the app will continue. It appears that this will cause no other harm and reading the the archive will keep it’s integrity in case other data follows.

I am confused by why command statistic info is stored for a command that I didn’t register but yet the Prof-UIS "Show or Hide Panels" menu can display it. Is this a bug?

David Skok Dec 13, 2006 - 12:52 PM

I should point out that when I say I do NOT include the toolbar commands in any of my menus I am referring to the toolbar show/hide commands, not the individual toolbar commands.

Technical Support Dec 15, 2006 - 3:49 AM

Try updating the command manager using g_CmdManager->UpdateFromToolBar() method. This is enough to make the commands’ icons available in the command manager. So you do not need to create an additional toolbar.