自绘控件接收不到WM_LBUTTONDOWN消息,各位帮忙看下
以下是代码,我练习绘制了一个控件,继承自CWnd,然后控件绘制在对话框上面了,奇怪的是点击对话框却接不到 鼠标点击消息,而键盘消息却能够在PreTranslateMessage中有反应.哪位大哥 对这个很熟悉的 请给指点一二,分不够我再加.谢谢
class CMyctrltab :
public CWnd
//我在对话框中创建了一个对象,然后有调用这个函数
void CMyctrltab::SetTab(CRect rcTab, CWnd * pParent, UINT uID)
{
// ClassName=_T("BUTTON" or "COMBOBOX" or "EDIT"
// or "LISTBOX" or "MDICLIENT" or
// "SCOLLBAR" or "STATIC")
this->Create(_T("STATIC"), NULL, WS_CHILD | WS_VISIBLE,
rcTab, pParent, uID);
char me[100];
sprintf(me,"%d",rcTab.top);
}
BEGIN_MESSAGE_MAP(CMyctrltab, CWnd)
ON_WM_LBUTTONDOWN()
ON_WM_PAINT()
END_MESSAGE_MAP()
void CMyctrltab::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
OutputDebugStringA("MY GOD");
CWnd::OnLButtonDown(nFlags, point);
}
void CMyctrltab::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CWnd::OnPaint()
CBrush m(RGB(255,0,255));
dc.SelectObject(&m);
dc.PatBlt(200,0,300,100,PATCOPY);
OutputDebugStringA("liumang");
}
BOOL CMyctrltab::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_LBUTTONDOWN)
{//接不到这个消息,都是被对话框那边接走了,就是这里最郁闷
OutputDebugStringA("found message Lbuttondown");
return true;
}
if (pMsg->message == WM_KEYDOWN)
{
OutputDebugStringA("KEY");
return true;
}
//OutputDebugStringA("messgae");
return true;
}