|
#pragma once
#include "resource.h"
#include "SendCmd.h"
#include "ToolButton.h"
#define BAR_FIRST_MENU_ID 3000
#define BAR_FIRST_BUTTON_ID 4000
struct MenuItemTag
{
public:
MenuItemTag(UINT flags, UINT ids, CString name, CString cmd) : menuName(name),menuCmd(cmd)
{
nFlags = flags;
nIds = ids;
}
MenuItemTag(const MenuItemTag& other)
{
nFlags = other.nFlags;
nIds = other.nIds;
menuName = other.menuName;
menuCmd = other.menuCmd;
}
MenuItemTag& operator = (const MenuItemTag &other)
{
if (this != &other)
{
nFlags = other.nFlags;
nIds = other.nIds;
menuName = other.menuName;
menuCmd = other.menuCmd;
}
return *this;
}
public:
UINT nFlags;//MF_STRING, MF_SEPARATOR,MF_SUBPOP
UINT nIds;
CString menuName;
CString menuCmd;
};
typedef std::vector<MenuItemTag> MenuGroup;
typedef std::map<CString, MenuGroup> MenuMap;
typedef std::map<UINT, CString> MenuCmdMap;
class CBarDlg : public CAcUiDialogBar
{
DECLARE_DYNAMIC(CBarDlg)
public:
CBarDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~CBarDlg();
// 对话框数据
enum { IDD = IDD_DIALOG_MENUBAR };
//一系列button
std::vector<CToolButton*> m_buttons;
MenuMap m_map;
MenuCmdMap m_cmdMap;
void InitMenuMap();
//弹出菜单
CMenu m_popMenu;
void PopupMenu(CString titleName, UINT nCtrlId);
void CreateSubPopupMenu(CMenu &popMenu, CString titleName);
CPoint GetTrackPnt(UINT nCtlrId);
void OnToolButtonClick(UINT buttonId);
void OnPopupMenuItemClick(UINT menuId);
std::vector<CString> GetMenu(CString menuPath);
void CreateButton(std::vector<CString>& button);
void CreateMenu(std::vector<CString>& button);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
DECLARE_MESSAGE_MAP()
protected:
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg LRESULT OnInitDialog(WPARAM, LPARAM);
}; |
|