如果因为变量问题,而不便在控件本身的消息处理函数中处理消息,可将消息发到父窗口处理。如鼠标消息 :
BOOL COwnBitmapBtn::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此添加专用代码和/或调用基类
if ((pMsg->message >= WM_MOUSEFIRST) && (pMsg->message <= WM_MOUSELAST))
{
//dispatch mouse message to parent window
CWnd *pParent = GetParent();
if (pParent != NULL)
{
pParent->SendMessage(pMsg->message, pMsg->wParam,
MAKELPARAM(pMsg->pt.x, pMsg->pt.y));
}
return TRUE;
}
return CBitmapButton::PreTranslateMessage(pMsg);
}