/** * @file XTPMenuBar.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPMENUBAR_H__) # define __XTPMENUBAR_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" # define XTP_IDR_MENUBAR 1 // Menu Bar class CXTPCommandBars; /** * @brief * CXTPMenuBarMDIMenuInfo structure used to describe the * parameters of application MDI menus. */ class _XTP_EXT_CLASS CXTPMenuBarMDIMenuInfo : public CXTPCmdTarget { public: /** * @brief * Constructs a CXTPMenuBarMDIMenuInfo object. * @param pCommandBars Parent commandbars. * @param nIDResource Template identifier. */ CXTPMenuBarMDIMenuInfo(CXTPCommandBars* pCommandBars, UINT nIDResource); /** * @brief * Destroys a CXTPMenuBarMDIMenuInfo object, handles cleanup and deallocation. */ ~CXTPMenuBarMDIMenuInfo(); public: CXTPControls* m_pControls; /**< Menu controls. */ CString m_strTitle; /**< Title of MDI menu. */ CString m_strDescription; /**< Description of MDI menu. */ HICON m_hIcon; /**< Menu Icon. */ UINT m_nIDResource; /**< Template identifier. */ BOOL m_bChanged; /**< TRUE if menu was changed. */ # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPMenuBarMDIMenuInfo); LPDISPATCH OleGetControls(); /** @endcond */ # endif }; class CXTPMenuBar; /** * @brief * CXTPMenuBarMDIMenus represents a collection of MDI menus for CXTPMenuBar. */ class _XTP_EXT_CLASS CXTPMenuBarMDIMenus : public CXTPCmdTarget { public: /** * @brief * Constructs a CXTPMenuBarMDIMenus object. * @param pMenuBar Parent CXTPMenuBar. */ CXTPMenuBarMDIMenus(CXTPMenuBar* pMenuBar); /** * @brief * Destroys a CXTPMenuBarMDIMenus object, handles cleanup and deallocation. */ ~CXTPMenuBarMDIMenus(); public: /** * @brief * Gets the number of MDI menus in the collection. * @return * The number of MDI menus in the collection. */ int GetCount() const; /** @cond */ void SetAt(UINT nIDResource, CXTPMenuBarMDIMenuInfo* pInfo); CXTPMenuBarMDIMenuInfo* Lookup(UINT nIDResource) const; void Remove(UINT nIDResource); void RemoveAll(); POSITION GetStartPosition() const; void GetNextMenu(POSITION& pos, CXTPMenuBarMDIMenuInfo*& pInfo) const; /** @endcond */ # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPMenuBarMDIMenus); LPDISPATCH OleGetItem(UINT nID); LPDISPATCH OleAdd(UINT nID, LPCTSTR lpszTitle, LPCTSTR lpszDescription); DECLARE_ENUM_VARIANTLIST(CXTPMenuBarMDIMenus); /** @endcond */ # endif protected: CMap m_mapMenus; /**< Menu map. */ CXTPMenuBar* m_pMenuBar; /**< Parent Menu Bar. */ }; /** * @brief * CXTPMenuBar is a CXTPToolBar derived class. * It represents a menu bar of a frame window. */ class _XTP_EXT_CLASS CXTPMenuBar : public CXTPToolBar { public: /** * @brief * Constructs a CXTPMenuBar object. */ CXTPMenuBar(); /** * @brief * Destroys a CXTPMenuBar object, handles cleanup and deallocation. */ ~CXTPMenuBar(); public: /** * @brief * Loads a menu from the resource. * @param nIDResource Menu identifier to load. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL LoadMenuBar(UINT nIDResource); /** * @brief * Destroy all MDI menus. */ void FreeMDIMenus(); /** * @brief * This member function will refresh the menus. */ void RefreshMenu(); /** * @brief * Call this method to retrieve the identifier of the currently visible menu. * @return * The identifier of the currently visible menu. */ UINT GetCurrentMenuResource() const; /** * @brief * Call this method to retrieve the identifier of the default menu. * @return * The identifier of the default menu. */ UINT GetDefaultMenuResource() const; /** * @brief * Retrieves the collection of application MDI menus. * @return * A pointer to the collection of application MDI menus. */ CXTPMenuBarMDIMenus* GetMDIMenus() const; /** * @brief * This method is called to switch to an MDI menu from the MDI menus collection. * @param nIDMenu Menu identifier to switch. * @param pMenu Menu to switch. * @see * SwitchActiveMenu */ virtual void SwitchMDIMenu(UINT nIDMenu, CMenu* pMenu = NULL); /** * @brief * Call this method to manually load an MDI menu in application initialization. * @param nIDResource Template identifier * @return * A pointer to a newly created menu information object or a pointer to * the existing menu information object if it has been previously added. */ CXTPMenuBarMDIMenuInfo* AddMDIMenu(UINT nIDResource); /** * @brief * Call this method to switch the menu to the active document menu. * @see * GetActiveDocTemplate, SwitchMDIMenu */ void SwitchActiveMenu(); /** * @brief * Call this method to reset the controls to their original states. * @param bShowWarningMessage TRUE to show warning message. */ virtual void Reset(BOOL bShowWarningMessage); protected: /** * @brief * This member function is called by WindowProc, or is called during * message reflection. * @param hWnd Window handle message belongs to. * @param nMessage Specifies the message to be sent. * @param wParam Specifies additional message-dependent information. * @param lParam Specifies additional message-dependent information. * @param lResult The return value of WindowProc. Depends on the message; * may be NULL. * @return A non-zero value if a hooked message is processed, 0 otherwise. */ int OnHookMessage(HWND hWnd, UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); /** * @brief * Either reads this object from or writes this object to an archive. * @param pPX A CXTPPropExchange object to serialize to or from. */ void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * This method makes a copy of the command bar. * @param pCommandBar Command bar to be copied. * @param bRecursive TRUE to copy recursively. */ virtual void Copy(CXTPCommandBar* pCommandBar, BOOL bRecursive = FALSE); protected: /** * @brief * This method is called to create hooks for the main window. */ void SetupHook(); /** * @brief * This method is called to create the menu for the main window. */ void SetupMenu(); /** * @brief * Call this method to get the handle to the active MDI child window. * @param bMaximized If this parameter is not NULL, it is a pointer to a value * that indicates the maximized state of the MDI child window. * @return * The handle to the active MDI child window. */ HWND GetActiveMdiChildWnd(BOOL* bMaximized = NULL); /** * @brief * Call this method to update the active MDI window hooks. */ void SyncActiveMdiChild(); /** * @brief * Call this method to update the system buttons of the menu bar. */ virtual void RefreshSysButtons(); /** * @brief * Call this method to switch the current MDI menu. * @param hMenu Active menu to select. */ void SwitchMDIMenu(HMENU hMenu); /** * @brief * Call this method to assign self-identifiers for the serialization process. * @param nID Identifier to assign. * @param pCommandBarList List of CommandBars. * @param pParam Address of an XTP_COMMANDBARS_PROPEXCHANGE_PARAM structure. */ void GenerateCommandBarList(DWORD& nID, CXTPCommandBarList* pCommandBarList, XTP_COMMANDBARS_PROPEXCHANGE_PARAM* pParam); /** * @brief * Call this method during the serialization process to restore pop-ups from * a list of command bars. * @param pCommandBarList List of command bars. */ void RestoreCommandBarList(CXTPCommandBarList* pCommandBarList); /** * @brief * Call this method to check if the toolbar has changed and must be saved. * @return * TRUE if the toolbar has changed and must be saved, otherwise FALSE. */ BOOL ShouldSerializeBar(); virtual BOOL OnFrameMouseWheel(BOOL bForward); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_MSG(CXTPMenuBar) afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg void OnDestroy(); //}}AFX_MSG /** @endcond */ # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPMenuBar); afx_msg LPDISPATCH OleGetMDIMenus(); afx_msg void OleSwitchMDIMenu(int nId); /** @endcond */ # endif private: void AddSysButton(CXTPControl* pControl, int nId, LPCTSTR lpszParameter, int nBefore = -1); BOOL IsMDIMenusChanged(); BOOL IsOleDocumentActive(HWND hWndActiveChild) const; protected: BOOL m_bMdiApp; /**< TRUE if parent frame is CMDIFrameWnd derived. */ HWND m_hWndActiveChild; /**< Active MDI window handle. */ HMENU m_hMenuDefault; /**< Default menu handle. */ UINT m_nIDResource; /**< Resource of default menu. */ UINT m_nIDResourceCurrent; /**< Currently active menu. */ CXTPMenuBarMDIMenus* m_pMDIMenus; /**< MDI menus. */ private: BOOL m_bDirtyMenu; private: DECLARE_XTP_COMMANDBAR(CXTPMenuBar) class CControlMDIButton; class CControlMDISysMenuPopup; friend class CXTPCommandBars; friend class CControlMDIButton; friend class CCommandBarsSite; friend class CCommandBarsCtrl; }; AFX_INLINE UINT CXTPMenuBar::GetCurrentMenuResource() const { return m_nIDResourceCurrent; } AFX_INLINE UINT CXTPMenuBar::GetDefaultMenuResource() const { return m_nIDResource; } AFX_INLINE CXTPMenuBarMDIMenus* CXTPMenuBar::GetMDIMenus() const { return m_pMDIMenus; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPMENUBAR_H__) /** @endcond */