帮忙看看BOOL CResGridView::PreTranslateMessage(MSG* pMsg)中的错误

swimmingfish2004 2004-08-11 10:38:01
BOOL CResView::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if ( pMsg->message == WM_COMMAND )
{
if ( pMsg->wParam == ID_POPUP_ADD)
{
CDlg Dlg;
Dlg.DoModal();
}
}
return CView::PreTranslateMessage(pMsg);
}
点了弹出菜单后,弹出对话框.点击对话框上的确定或者取消.就出错了.调试过程中发现是return 行出错.请各位高手指点一下.
...全文
78 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
No9 2004-08-13
  • 打赏
  • 举报
回复
if ( pMsg->message == WM_COMMAND )
{
if ( pMsg->wParam == ID_POPUP_ADD)
{
CDlg Dlg;
Dlg.DoModal();
//***********************************
return TRUE;
//***********************************
}
}
既然你已经处理了,就应该返回TRUE,表示已经处理过了!
lixiaosan 2004-08-13
  • 打赏
  • 举报
回复
就是就是,你直接给ID_POPUP_ADD添加消息映射不就得了,

这样截获消息不是多此一举
flyelf 2004-08-11
  • 打赏
  • 举报
回复
为什么不直接为ID_POPUP_ADD添加消息映射呢

Dlg.DoModal();
return TRUE;
CPPToolTip控件 链接:http://www.codeproject.com/KB/miscctrl/pptooltip.aspx 截图: 1 CPPToolTip控件介绍 Files Description PPTooltip.h PPTooltip.cpp CPPTooltip class PPHtmlDrawer.h PPHtmlDrawer.cpp CPPHtmlDrawer class. It's need to drawing HTML string in tooltip body PPDrawManager.h PPDrawManager.cpp CPPDrawManager class is a set of methods to work with graphics. CeXDib.h CeXDib.cpp CCeXDib class thanks to Davide Pizzolato and Davide Calabro. This class use for extend background's effect. Extend background effects by Davide Pizzolato and Davide Calabro become available if defined USE_SHADE: in PPDrawManager.h #define USE_SHADE 2 在普通窗体控件使用 2.1 创建CPPToolTip对象 CPPToolTip m_tooltip; 2.2 在窗口初始化函数OnInitDialog: // Create the CPPToolTip object m_tooltip.Create(this); 2.3 添加提示控件 m_tooltip.AddTool(GetDlgItem(IDC_BUTTON1), _T("Tooltip to the control IDC_BUTTON1")); 或者: m_tooltip.AddTool(this, _T("Tooltip for rectangle area"),CRect (100, 100, 200, 200)); 2.4 拦截处理鼠标消息 BOOL ... ::PreTranslateMessage(MSG* pMsg) { m_tooltip.RelayEvent(pMsg); } 3 在工具栏使用 3.1 在CMainFrame定义CPPToolTip对象 CPPToolTip m_tooltip; 3.2 在CMainFrame的OnCreate函数创建CPPToolTip对象,添加工具栏提示 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { ... m_tooltip.Create(this); //Adds tooltip for toolbar m_tooltip.AddToolBar(&m_wndToolBar); return 0; } 3.3 截取和处理鼠标消息 BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { m_tooltip.RelayEvent(pMsg); } 4 在菜单使用 4.1 在CMainFrame定义CPPToolTip变量 CPPToolTip m_tooltip; 4.2 在CMainFrame的OnCreate()函数创建CPPToolTip对象 m_tooltip.Create(this); 4.3 Uncomments a line to enable a work with menus. in PPTooltip.h #define PPTOOLTIP_USE_MENU 4.4 为CMainFrame添加两个事件处理对象 //选菜单事件 void CMainFrame::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSubMenu) { m_tooltip.OnMenuSelect(nItemID, nFlags, hSubMenu); CFrameWnd::OnMenuSelect(nItemID, nFlags, hSubMenu); } //闲置状态事件 void CMainFrame::OnEnterIdle(UINT nWhy, CWnd* pWho) { m_tooltip.OnEnterIdle(nWhy, pWho); } 4.5 截取和处理鼠标消息 BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { m_tooltip.RelayEvent(pMsg); }

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧