In head file:class CDraw : public CWnd
{
// Construction
public:
CDraw();// Attributes
public:
CDrawWav m_drawWav;// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDraw)
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CDraw(); // Generated message map functions
protected:
//{{AFX_MSG(CDraw)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_DRAW_H__F8886CFD_9D22_488C_8E27_A32E0A5CF53A__INCLUDED_)In the cpp file:
void CDraw::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
MessageBox( "Me Clicked!","提示!",MB_OK);
CWnd::OnLButtonDblClk(nFlags, point);
}void CDraw::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
GetClientRect(*this,rect);
// if(point.y>rect.bottom-2)
MessageBox("adfadf");
CWnd::OnMouseMove(nFlags, point);
}在MFC单文档窗口中我申明了该类的实例,该类的实例已经显示在单文档窗口了,在显示的位置双击鼠标左键没有任何反映,鼠标在该窗口下部移动也没任何反映,还需要做些什么,才能够对消息做出响应呢?困惑......
{
// Construction
public:
CDraw();// Attributes
public:
CDrawWav m_drawWav;// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDraw)
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CDraw(); // Generated message map functions
protected:
//{{AFX_MSG(CDraw)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_DRAW_H__F8886CFD_9D22_488C_8E27_A32E0A5CF53A__INCLUDED_)In the cpp file:
void CDraw::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
MessageBox( "Me Clicked!","提示!",MB_OK);
CWnd::OnLButtonDblClk(nFlags, point);
}void CDraw::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
GetClientRect(*this,rect);
// if(point.y>rect.bottom-2)
MessageBox("adfadf");
CWnd::OnMouseMove(nFlags, point);
}在MFC单文档窗口中我申明了该类的实例,该类的实例已经显示在单文档窗口了,在显示的位置双击鼠标左键没有任何反映,鼠标在该窗口下部移动也没任何反映,还需要做些什么,才能够对消息做出响应呢?困惑......
OnMouseMove(UINT nFlags, CPoint point); 在线等!
加上
BEGIN_MESSAGE_MAP(CMy111View, CView)
//{{AFX_MSG_MAP(CMy111View)
ON_WM_LBUTTONDBLCLK()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//{{AFX_MSG_MAP(CDraw)
ON_WM_CREATE()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_LBUTTONDBLCLK()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()那是CLASS Wizard 自动加的,肯定不会少的了。
我又不是自己用 notepat 来编辑代码,老兄?
WS_POPUP可以WS_CHILD好像不能接受消息啊
class CDraw : public CWnd;在别的窗口(可以是对话框、单文挡、或多文档)申明实例,
CDraw m_draw;
在该窗口
CRect rect;
GetClientRect(rect);
m_draw.Create( "button", "",WS_CHILD | WS_VISIBLE, CRect(rect.left+2, rect.top+2, rect.right-2, 100), this, IDOK,NULL);
m_draw.ShowWindow(SW_SHOW);
非常感谢你啊!
CRect rect;
GetClientRect(rect);
m_draw.Create( "button", "",WS_CHILD | WS_VISIBLE, CRect(rect.left+2, rect.top+2, rect.right-2, 100), this, IDOK,NULL);
m_draw.ShowWindow(SW_SHOW);
就可以了(Debug不能通过,要Realse)因为Debug有一个 ASSERT((dwStyle & WS_POPUP) == 0);
m_draw.Create(NULL,NULL,WS_VISIBLE|WS_POPUP, CRect(rect.left+2, 100, rect.right-2, 200), this,0);
能在改改什么吗?