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 » receive message form ribbonnode Collapse All
Subject Author Date
Ulrich Heinicke Sep 12, 2007 - 3:05 PM

I add into the example RibbonBarMdi in the file mainfrm.cpp into the message map the following:
    ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
and the function:
void CMainFrame::OnEditPaste()
{
    AfxMessageBox("EditPaste");
}
Into the function _InitRibbonNode_Home_Clipboard you add a ribbonnode with the cmdid ID_EDIT_PASTE. But when i press the ribbon button i can’t get the messagebox. So please tell me, how i can receive the message.
Thanks
Ulrich

Technical Support Oct 8, 2007 - 2:03 PM

We are sorry but we did not receive it. Please send it to us again. If you did not exclude some binary files from your project and the attachment was big enough, it may have been filtered out somewhere.

Ulrich Heinicke Oct 7, 2007 - 4:05 AM

I have send you my source code per email at 9/27. You hav recieved it ? Do you have find the error ?
Ulrich

Technical Support Sep 21, 2007 - 8:25 AM

There are no differences in the ribbon code available in 2.80 and 2.81 you have. We believe the problem is hidden somewhere else what is not discussed yet. Would you allow us in some way to look at your source code, e.g., via a remote desktop?

Ulrich Heinicke Sep 21, 2007 - 4:34 AM

I find out what is going wrong. First i compile it with VS2003 and the version 2.80 and everything works fine. After that i compile it with the version 2.81 from 6. of sept. and i got a fault. So there must be an error into the new code handling the commands.
Ulrich

Technical Support Sep 18, 2007 - 11:38 AM

The CN_COMMAND notifications are invoked both for handling commands and detecting whether the handler method is present. So, you should not ignore the pExtra != NULL condition and simply return TRUE in this case without displaying the message box (handling command). Please send us a modified version of our sample application (to avoid any misunderstanding) so we can find out what is wrong.

Ulrich Heinicke Sep 17, 2007 - 4:13 PM

I have used the above OnCmdMsg, but it doesn’t work. So i try the RibbonMDI example. I remove in the OnCmdMsg the comment mark for the ID_EDIT_COPY. So the code looks like :
    if( nID == ID_EDIT_COPY && nCode == CN_COMMAND && pExtra == NULL )
    {
        int x = 0;
        x;
        AfxMessageBox("Edit Copy");
        return TRUE;
    }
But the Messagebox is not displayed. Is there a problem with the version 2.81 you have send me?
When i remove pExtra == NULL, then i get many Messageboxes.
Thanks
Ulrich

Ulrich Heinicke Sep 17, 2007 - 7:22 AM

I send the following code into my project:
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{

    if (nID == ID_HOLZ_BALKEN && nCode == CN_COMMAND && pExtra == NULL)
    {
#ifdef _TTRACE
        TTrace::Debug()->Send("NewWoodBeam");
#endif
        int i;
        theApp.m_nChoise = 0;
        theApp.CreateNewDocument(HSBALKENPROG);
    }

    return CExtNCW < CMDIFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
}
CExtRibbonNode * CMainFrame::_InitRibbonPage_Home()
{
    CExtRibbonNodeTabPage * pRibbonNodeTabPage = new CExtRibbonNodeTabPage( 0L, NULL, _T("Holzbau") );
    pRibbonNodeTabPage->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’H’) ) ), false );

    CExtRibbonNodeGroup * pRibbonGroup =
        new CExtRibbonNodeGroup( ID_RIBBON_PAGE_WOOD );

    CExtRibbonNode * pNodeFileNew =
        new CExtRibbonNode(
        ID_HOLZ_BALKEN,
        0,
        NULL,
        0,
        NULL,
        _T("&Durchlauftrager")
        );

    CExtSkinBitmap m_bmpNew;
    HICON hIcon = theApp.appIcons.GetAt(0);
    m_bmpNew.AssignFromHICON(hIcon);
    pNodeFileNew->m_iconBig.m_bmpNormal = m_bmpNew;
    pNodeFileNew->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’N’) ) ), false );
    pRibbonGroup->InsertNode( NULL, pNodeFileNew );
    pRibbonNodeTabPage->InsertNode( NULL, pRibbonGroup );

    return pRibbonNodeTabPage;
}
but i can’t receive the message. Could you tell me what’s wrong ? It’s a little bit difficulte to move from my old GUI.
Thanks
Ulrich

Technical Support Sep 17, 2007 - 8:48 AM

You could improve your CMainFrame::OnCmdMsg() method in this way

BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
      if( nID == ID_HOLZ_BALKEN && nCode == CN_COMMAND )
      {
            if(pExtra == NULL )
            {
#ifdef _TTRACE
                  TTrace::Debug()->Send("NewWoodBeam");
#endif
                  int i;
                  theApp.m_nChoise = 0;
                  theApp.CreateNewDocument(HSBALKENPROG);
            }
            return TRUE;
      }
      return CExtNCW < CMDIFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
}
Now command ID_HOLZ_BALKEN should work OK.

Technical Support Sep 13, 2007 - 11:18 AM

You may have already noticed that the RibbonBarMDI sample has all buttons and menu items in the ribbon bar always enabled regardless of the fact we did not implement handler methods for these commands. We have handled/updated all the commands at once in the CMainFrame::OnCmdMsg() method which contains the following code near the end of this method:

      CExtNCW < CMDIFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
      return TRUE;
Please do not forget to replace the following lines above with this line in your real project:
      return CExtNCW < CMDIFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
But this is not what causes the problem when the handler for the ID_EDIT_PASTE command is not invoked. We guess you simply inserted a message map entry for it into the message map of some other class instead of the CMainFrame class. We have repeated your experiment with the RibbonBarMDI sample and the message box was displayed. Please download the following ZIP file containing our updated version of the MainFrm.h and MainFrm.cpp files for the RibbonBarMDI sample:

UpdatedMainFrmForRibbonBarMDI.zip