📄 bcgmenubar.h
字号:
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This source code is a part of BCGControlBar library.
// You may use, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES on your own risk.
//
// Stas Levin <stas@iet.co.il>
//*******************************************************************************
#if !defined(AFX_BCGMENUBAR_H__644FE23B_D1DB_11D1_A649_00A0C93A70EC__INCLUDED_)
#define AFX_BCGMENUBAR_H__644FE23B_D1DB_11D1_A649_00A0C93A70EC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// BCGMenuBar.h : header file
//
#include "BCGToolBar.h"
#include "bcgcontrolbar.h"
class CBCGToolbarMenuButton;
class CBCGToolbarSystemMenuButton;
class CBCGToolbarMenuButtonsButton;
#define BCG_IDW_MENUBAR 0xE806 // CBCGMenuBar
/////////////////////////////////////////////////////////////////////////////
// CBCGMenuBar window
class BCGCONTROLBARDLLEXPORT CBCGMenuBar : public CBCGToolBar
{
friend class CBCGOptionsPage;
friend class CBCGToolBar;
friend class CBCGPopupMenuBar;
DECLARE_SERIAL(CBCGMenuBar)
// Construction
public:
CBCGMenuBar();
// Attributes
public:
static BOOL IsShowAllCommands ()
{
return m_bShowAllCommands || !m_bRecentlyUsedMenus;
}
static BOOL IsRecentlyUsedMenus ()
{
return m_bRecentlyUsedMenus;
}
static BOOL IsShowAllCommandsDelay ()
{
return m_bShowAllMenusDelay;
}
static void SetShowAllCommands (BOOL bShowAllCommands = TRUE);
static BOOL SetMenuFont (LPLOGFONT lpLogFont, BOOL bHorz = TRUE);
static const CFont& GetMenuFont (BOOL bHorz = TRUE);
static void EnableMenuShadows (BOOL bEnable = TRUE)
{
m_bMenuShadows = bEnable;
}
static BOOL IsMenuShadows ()
{
return m_bMenuShadows;
}
BOOL m_bAutoDocMenus; // Automatically load/save document menus
protected:
CWnd* m_pParentWnd;
BOOL m_bMaximizeMode;
BOOL m_bActualMaximizeMode;
HMENU m_hMenu;
HMENU m_hDefaultMenu;
HMENU m_hSysMenu;
HICON m_hSysIcon;
UINT m_uiDefMenuResId;
int m_nSystemButtonsNum;
int m_nSystemButtonsNumSaved;
BOOL m_bHaveButtons;
CSize m_szSystemButton; // Syetm button size
static BOOL m_bShowAllCommands;
static BOOL m_bRecentlyUsedMenus;
static BOOL m_bShowAllMenusDelay;
static HHOOK m_hookMouseDrag;
static CBCGMenuBar* m_pDraggedMenuBar;
static BOOL m_bMenuShadows;
// Operations
public:
BOOL TranslateChar (UINT nChar);
void CreateFromMenu (HMENU hMenu, BOOL bDefaultMenu = FALSE);
void SetMaximizeMode (BOOL bMax, CWnd* pWnd = NULL);
void SetDefaultMenuResId (UINT uiResId);
UINT GetDefaultMenuResId () const
{
return m_uiDefMenuResId;
}
HMENU GetMenu () const
{
return m_hMenu;
}
HMENU GetDefaultMenu () const
{
return m_hDefaultMenu;
}
CBCGToolbarButton* GetMenuItem (int iItem) const;
CBCGToolbarSystemMenuButton* GetSystemMenu () const;
CBCGToolbarMenuButtonsButton* GetSystemButton (UINT uiBtn, BOOL bByCommand = TRUE) const;
protected:
void RestoreMaximizeMode ();
void SetDragMode (BOOL bOn);
static LRESULT CALLBACK BCGMenuBarMouseProc (int nCode, WPARAM wParam, LPARAM lParam);
static BOOL FindMenuItemText (HMENU hMenu, const UINT nID, CString& strText);
void CalcSysButtonSize ();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBCGMenuBar)
//}}AFX_VIRTUAL
public:
virtual BOOL Create(CWnd* pParentWnd,
DWORD dwStyle = dwDefaultToolbarStyle,
UINT nID = BCG_IDW_MENUBAR);
virtual CSize CalcDynamicLayout (int nLength, DWORD dwMode);
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcLayout(DWORD dwMode, int nLength = -1);
virtual void AdjustLocations ();
virtual BOOL OnSendCommand (const CBCGToolbarButton* pButton);
virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
virtual BOOL LoadState (LPCTSTR lpszProfileName = NULL, int nIndex = -1, UINT uiID = (UINT) -1);
virtual BOOL SaveState (LPCTSTR lpszProfileName = NULL, int nIndex = -1, UINT uiID = (UINT) -1);
virtual void OnCustomizeMode (BOOL bSet);
virtual BOOL CanBeRestored () const
{
return TRUE;
}
virtual BOOL CanBeClosed () const
{
return FALSE;
}
virtual BOOL AllowChangeTextLabels () const
{
return FALSE;
}
// ET: Hook for dynamic changes of the default menu
virtual void OnDefaultMenuLoaded (HMENU) {};
virtual BOOL RestoreOriginalstate ();
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual int GetRowHeight () const
{
return max (globalData.GetTextHeight (m_dwStyle & CBRS_ORIENT_HORZ),
m_bHaveButtons ?
GetButtonSize ().cy :
m_sizeMenuButton.cy <= 0 ?
m_sizeButton.cy - 2 : m_sizeMenuButton.cy - 2);
}
virtual int GetColumnWidth () const
{
return m_bHaveButtons ?
GetButtonSize ().cx :
m_sizeMenuButton.cx <= 0 ?
m_sizeButton.cx - 2 : m_sizeMenuButton.cx - 2;
}
virtual BOOL OnSetDefaultButtonText (CBCGToolbarButton* pButton);
virtual BOOL PrevMenu ();
virtual BOOL NextMenu ();
virtual void OnChangeHot (int iHot);
protected:
virtual int FindDropIndex (const CPoint point, CRect& rectDrag) const;
// Implementation
public:
virtual ~CBCGMenuBar();
// Generated message map functions
protected:
//{{AFX_MSG(CBCGMenuBar)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BCGMENUBAR_H__644FE23B_D1DB_11D1_A649_00A0C93A70EC__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -