문제

I've got some control like CtrlTree on CMyDialog. I want to handle messages like ON_WM_LBUTTONDOWN() from CTreeCtrl in the CMyDialog class.

Is there any way in MFC to redirect message stream to parent?

도움이 되었습니까?

해결책

The simplest way to redirect your messages is just sending a custom (WM_USER + xxx) message from your control's ON_WM_LBUTTONDOWN handler to the parent class.

Place parent's WM_LBUTTONDOWN handler code in a separate method and call this method directly.

Something like that (pseudo code), presuming that your existing code sits in HandleTreeCtrlLBDown()

CMyTreeCtrl::OnLButtonDown(..)
{
   pParent ->SendMessage(WM_TREECTRLLBDOWN, 0, (LPARAM)this);
}

CControlParentDialog::OnTreeCtrlLBDown(wParam, lParam)
{
   HandleTreeCtrlLBDown();
} 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top