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 » "2 Menubar Collapse All
Subject Author Date
Dirk lindner Jun 15, 2009 - 6:31 AM

Hello,
i have 2 MenuBars in one application.
One In the Mainframe and one in a dialog.
If i open the dialog the text from the dialog menu will be used for both MenuBars



Here is the sourcecode for the Menu classes.

//Mainframe MenuBar

#pragma once
#include "stdafx.h"
#include <Prof-UIS.h>
#include <ExtToolControlBar.h>


class CPrfMenuBar : public CExtMenuControlBar
{
public:
    bool RegisterToolBar(
                __EXT_MFC_SAFE_LPCTSTR lpszWindowName,
                CWnd* p_pParentWnd,
                UINT p_nIDR_ID )
        {

                if(    !Create(
                        lpszWindowName,
                        p_pParentWnd,
                        p_nIDR_ID
                    )
                )
                {
                    ASSERT( FALSE );
                }

                return true;
    }

protected:

BOOL _UpdateMenuBar(BOOL bDoRecalcLayout/* = TRUE */){
        CMenu * pMenu = GetMenu();
        UINT nItem = pMenu->GetMenuItemCount();

        for (UINT i = 0; i < nItem; i++){
            CString sString;
            pMenu->GetMenuString(i, sString, MF_BYPOSITION);

            /*    if( sString.Left(4).CompareNoCase(_T("@STR")) == 0 ){
            long nStringID = atol( sString.Mid(4) );
            if( nStringID )
            sString = g_oStrMngr.GetString( nStringID );
            }*/
            pMenu->ModifyMenu(i, MF_BYPOSITION, pMenu->GetMenuItemID(i) ,sString) ;
        }
        return CExtMenuControlBar::_UpdateMenuBar( bDoRecalcLayout);
}

};

And for the Dialog
#ifndef __EXTMINIDOCKFRAMEWND_H
#include <../Src/ExtMiniDockFrameWnd.h>
#include <ExtMenuControlBar.h>
#endif
#pragma once

class CPrfObjListMenuBar : public CExtMenuControlBar
{
public:
    bool RegisterToolBar(
        __EXT_MFC_SAFE_LPCTSTR lpszWindowName,
        CWnd* p_pParentWnd,
        UINT p_nIDR_ID )
    {
        g_CmdManager->ProfileSetup(PROFUIS_PROFILENAME, p_pParentWnd->GetSafeHwnd() );
        LoadMenuBar( p_nIDR_ID );
        return true;
    }
protected:
    virtual BOOL _UpdateMenuBar(
        BOOL bDoRecalcLayout = TRUE
        ){
            CMenu * pMenu = GetMenu();
            UINT nItem = pMenu->GetMenuItemCount();
            for (UINT i = 0; i < nItem; i++) {
                CString sString;
                pMenu->GetMenuString(i, sString, MF_BYPOSITION);
                //Translate it
                /*    if( sString.Left(4).CompareNoCase(_T("@STR")) == 0 ){

                long nStringID = atol( sString.Mid(4) );
                if( nStringID )
                sString = g_oStrMngr.GetString( nStringID );
                }*/
                pMenu->ModifyMenu(i, MF_BYPOSITION, pMenu->GetMenuItemID(i) ,sString) ;
            }

            return CExtMenuControlBar::_UpdateMenuBar( bDoRecalcLayout);
        }
        /*!\fn OnCreateBarRightBtn versteckt den rechten BarButton*/
        virtual CExtBarContentExpandButton * OnCreateBarRightBtn(){return NULL; }
};


Any Idea ?



Dirk lindner Jun 18, 2009 - 4:50 AM

Thank, this works fine !

Dirk Lindner

Technical Support Jun 15, 2009 - 12:48 PM

There is one very important limitation related to the CExtMenuControlBar window: each menu bar must be the only one menu bar in scope of the Prof-UIS command manager’s command profile. This means your dialog should initialize a unique command profile for itself and for all its child windows including the menu bar. You can invoke g_CmdManager->ProfileSetup( _T("profile-name-for-dialog"), hWndOfDialog ) in the dialog’s OnInitDialog() virtual method and the g_CmdManager->ProfileDestroy( _T("profile-name-for-dialog") ) code in the dialogs OnOK() and OnCancel() methods.