#if !defined(__KTMENUCTRL_H__) #define __KTMENUCTRL_H__ #if _MSC_VER > 1000 #pragma once #endif #include "KTMenuPopup.h" #include "KTMenuResource.h" class CAcadPopupMenu; class KTMenuCtrl : public CWnd { DECLARE_DYNCREATE(KTMenuCtrl) public: KTMenuCtrl(); virtual ~KTMenuCtrl(); virtual long LoadMenu(LPCTSTR pszFile,LPCTSTR pszTitle,int nIndex); void SetMenu(KTMenuPopup* pMenu); KTMenuItem* GetMenuItem(int iIndex); HBITMAP GetResourceIcon(LPCTSTR pszRes) {return m_mnRrc.GetResourceIcon(m_hResource, pszRes);} int HitTest(LPPOINT pPt,UINT* pFlag = NULL); BOOL GetItemRect(int iIndex, CRect& rcItem); BOOL TrackPopupMenu(UINT nFlag, LPPOINT pPt, int iIndex); protected: UINT BuildItem(KTMenuPopup* pMenu); UINT OnBuildItem(KTMenuPopup* pMenu, KTMenuPopup* pSub); UINT GetItemState(int iIndex, UINT* pSub = NULL); BOOL OnItemUpdate(CCmdUI* pCmdUI); int FindItem(KTMenuItem* pItem); void OnSetMessage(int iIndex); void OnSetMessage(KTMenuItem* pItem); KTMenuItem* GetTrackItem(UINT nID); void OnTrackClicked(UINT nID); void OnExecuteCmd(KTMenuItem* pItem); void DrawItem(CDC* pDC); void MeasureItem(KTMenuPopup* pMenu); void OnItemClicked(int iIndex); void SubOnItemClicked(int iIndex, CPoint& point); void AddAutoCADMenu(LPCTSTR pszTitle,int nPos); bool AddAutoCADSubMenu(KTMenuItem* pSubItem,CAcadPopupMenu* pIPopUpMenuSub,int j); BOOL m_bLDown; int m_iCurSel; int m_iOffset; int m_iHeight; CPtrArray m_arpItems; CImageList m_imglstIcon; CImageList m_imgHelpIcon; CMapPtrToWord m_mapCmd2HelpFlag; KTMenuPopup m_mnScreen; HINSTANCE m_hResource; KTMenuResource m_mnRrc; KTMenuPopup* m_pMenu; KTMenuItem* m_pTrack; CFont m_font; // 文字物理高度 float m_iPhysical_height_of_text; public: virtual BOOL Create(CWnd* pParentWnd, DWORD dwStyle, const RECT& rect, UINT nID); protected: virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); public: afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnPaint(); afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu); afx_msg void OnCaptureChanged(CWnd *pWnd); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct); afx_msg void OnDestroy(); DECLARE_MESSAGE_MAP() protected: void DrawHelp(CDC *pDC, KTMenuItem *pItem, CRect &rcText); }; #endif