zoukankan      html  css  js  c++  java
  • 菜单项说明以提示弹出

    class CSDI01View : public CWindowImpl<CSDI01View>
    {
    	CMenuHandle m_TrackMenu;
    	CToolTipCtrl m_ToolTip;
    public:
    	DECLARE_WND_CLASS(NULL)
    
    	BOOL PreTranslateMessage(MSG* pMsg)
    	{
    		pMsg;
    		return FALSE;
    	}
    
    	BEGIN_MSG_MAP(CSDI01View)
    		MESSAGE_HANDLER(WM_CREATE, OnCreate)
    		MSG_WM_CONTEXTMENU(OnContextMenu)
    		MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect)
    		MESSAGE_HANDLER(WM_PAINT, OnPaint)
    	END_MSG_MAP()
    
    // Handler prototypes (uncomment arguments if needed):
    //	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    //	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    //	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
    
    	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    	{
    		CPaintDC dc(m_hWnd);
    
    		//TODO: Add your drawing code here
    
    		return 0;
    	}
    	
    	LRESULT OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    	{
    		UINT nItemID = (UINT)LOWORD(wParam);
    		UINT nFlags = (UINT)HIWORD(wParam);
    		CMenuHandle menu = (HMENU)lParam;
    		if (m_TrackMenu.GetSubMenu(0) == menu)
    		{
    			m_ToolTip.UpdateTipText(nItemID, m_hWnd);
    			CRect rc;
    			UINT nPos =0, nItemCount = menu.GetMenuItemCount();
    			// Get Item Position
    			for (; nPos < nItemCount; nPos++)
    			{
    				if (menu.GetMenuItemID(nPos) == nItemID)
    				{
    					break;
    				}
    			}
    			int nRes = menu.GetMenuItemRect(NULL, nPos, &rc);
    			ATLTRACE("GetMenuItemRect() return %d \nMenu item coordinate(right,top):(%d,%d)\n", nRes, rc.right, rc.top);
    			CRect rcTip;
    			CToolInfo toolInfo(TTF_TRACK, m_hWnd);
    			m_ToolTip.GetToolInfo(&toolInfo);
    
    			m_ToolTip.GetWindowRect(&rcTip);
    			rcTip.MoveToXY(rc.right + 5, rc.top);
    
    			m_ToolTip.TrackActivate(&toolInfo, TRUE);
    			m_ToolTip.MoveWindow(&rcTip);
    		}
    		return 0;
    	}
    	
    	void OnContextMenu(CWindow wnd, CPoint point)
    	{
    		CMenuHandle menu;
    		m_TrackMenu.LoadMenu(IDR_MENU1);
    		menu.Attach(m_TrackMenu.GetSubMenu(0));
    		m_ToolTip.Activate(TRUE);
    		ATLTRACE("OnContextMenu() :point(%d,%d)\n",point.x, point.y);
    		menu.TrackPopupMenu(TPM_RIGHTBUTTON, point.x, point.y, m_hWnd);
    		m_TrackMenu.DestroyMenu();
    		m_ToolTip.Activate(FALSE);
    	}
    	
    	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    	{
    		//LPCREATESTRUCT lpCreateStruct = (LPCREATESTRUCT)lParam;
    		m_ToolTip.Create(m_hWnd);
    		m_ToolTip.AddTool(m_hWnd);
    		m_ToolTip.SetMaxTipWidth(0);
    		return 0;
    	}
    };

  • 相关阅读:
    MVC中的helper标签
    自适应网页设计(Responsive Web Design)
    网站设计的最简主义
    Windows Forms数据绑定技术
    [C#]写自己的类库
    C#数据库连接字符串
    CSS float属性
    CSS之UL
    NET教程:MVC4使用Bundling,CSS中图片路径问题
    ASP.net 中Get和Post的用法
  • 原文地址:https://www.cnblogs.com/qianwen36/p/3657432.html
Copyright © 2011-2022 走看看