views:

459

answers:

1

I have a custom CTabCtrl which I am trying to customize (to automatically change pages).

If I handle ON_NOTIFY_REFLECT(TCN_SELCHANGE, ...) in my tab control, ON_NOTIFY(TCN_SELCHANGE, ...) is not received by the parent class.

How can I receive both notify messages in the child and parent classes?

Currently I am using a "workaround" of manually sending the WM_NOTIFY message to the parent class:

void CMyTabControl::OnSelChange(NMHDR *pHeader, LRESULT *pResult)
{
    const int index = this->GetCurSel();
    this->ShowTab(index);

    const CWnd *const pParent = this->GetParent();
    if (pParent != NULL)
    {
        *pResult = pParent->SendMessage(WM_NOTIFY, TCN_SELCHANGE, 
            reinterpret_cast<LPARAM>(pHeader));
    }
}

Edit: I've tried both *pResult = 0 and *pResult = 1 but it still doesn't send the message onto the parent. Also, I've noticed that when I send the message on to the parent I end up in an almost infinite loop (for some reason it does break out after several iterations).

A: 

I've found the answer:

http://msdn.microsoft.com/en-us/library/eeah46xd.aspx

Basically you have to use ON_NOTIFY_REFLECT_EX and then return FALSE from your function to enable the parent notify message to be fired.

Mark Ingram