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 General Discussion » Command update Collapse All
Subject Author Date
Henry Van Voorhis Apr 12, 2006 - 10:40 AM

in an ie toolbar I am trying to disable a button, I have added the ON_COMMAND handler but it only seems to be called (disabled) when I click the button, How can I force the update to be called?

I have tried:

GetParent()->SendMessage(WM_COMMAND, MAKELONG(ID_AUTOFILL_PASSCODE, BN_PAINT), (LPARAM)m_hWnd);

but this does not seem to do the trick...

Technical Support Apr 13, 2006 - 1:57 AM

You can invoke the command updating mechanism for a particular toolbar window with one line of code:

pToolBar->OnUpdateCmdUI( pTargetWnd, TRUE );
pTargetWnd specifies the command target window which has a command handler/updating method for your toolbar commands.

Henry Van Voorhis Apr 13, 2006 - 9:53 AM

What about when the toolbar is not a child of a CFrameWnd as in a IE toolbar?

Technical Support Apr 13, 2006 - 12:30 PM

There is no difference. The CExtToolControlBar::OnUpdateCmdUI() method works in any type of project.

Andrew Nanopoulos Apr 13, 2006 - 1:53 PM

The method has the signature:

    virtual void OnUpdateCmdUI(
        CFrameWnd * pTarget,
        BOOL bDisableIfNoHndler
        );

I am not sure how to pass a non-frame wnd (CWnd) into this?

Technical Support Apr 17, 2006 - 1:22 AM

You can update all the toolbar buttons with the following code:

CWnd * pTargetUpdateWnd = . . .
CExtToolControlBar * pToolBar = . . .
BOOL bDisableIfNoHndler = TRUE;
int nBtnIdx, nCountOfButtons = pToolBar->GetButtonsCount();
    for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
    {
        CExtBarButton * pTBB = pToolBar->GetButton( nBtnIdx );
        ASSERT_VALID( pTBB );
        pTBB->OnUpdateCmdUI(
            pTargetUpdateWnd,
            bDisableIfNoHndler,
            nBtnIdx
            );
    }