I override my PreTranslateMessage function in my dialog, but when i right click the CTreeCtrl control the first time, the Menu loaded as i expected, but when i right click the second time, the Menu disappeared. and the third time the menu loaded again, and fourth it disappeared.
i want to understand the mechmanism of the message routing.
the problem code is here.
if(WM_RBUTTONDOWN==pMsg->message)
{
DWORD dwPos = GetMessagePos();
CPoint point(LOWORD(dwPos), HIWORD(dwPos));
CMenu menu;
VERIFY(menu.LoadMenu(IDR_RCLKMENU));
CMenu *popup=menu.GetSubMenu(0);
ASSERT(popup!=NULL);
popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}
return CDialogEx::PreTranslateMessage(pMsg);
When i add one line code the problem disappear and works as i expceted.
if(WM_RBUTTONDOWN==pMsg->message)
{
DWORD dwPos = GetMessagePos();
CPoint point(LOWORD(dwPos), HIWORD(dwPos));
CMenu menu;
VERIFY(menu.LoadMenu(IDR_RCLKMENU));
CMenu *popup=menu.GetSubMenu(0);
ASSERT(popup!=NULL);
popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
return true; }
return CDialogEx::PreTranslateMessage(pMsg);
Thank you all.