OnContextMenu in a doc/view
Hi,
On the view derived from CView I have created a window using CWnd::Create. The context menu is shown correct no matter if I right click on the created child window or inside the view window itself. But the command e.g. ID_EDIT_COPY do not work if right click on the child window but the view window.
The child window eats the command.
How can I redirect the command to the parent window? I tried to use OnCmdMsg but this does not work. (stack overflow)
I already use OnCmdMsg in the view class because some commands should be sent to the child. I think that the command is sent from one OnCmdMsg to the other and back and....
Any idea?
Re: OnContextMenu in a doc/view
Please show us some code. ...post that two functions what are in the parent and in the child window(OnCmdMsg ).
Re: OnContextMenu in a doc/view
I usually just do this:
Code:
CPoint pt;
::GetCursorPos(&pt);
DWORD selection = popup_menu->TrackPopupMenu(
TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,
pt.x,
pt.y,
this);
view->PostMessage(WM_COMMAND,selection,0);
GL
Re: OnContextMenu in a doc/view
Thanks for the help!
pContextMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON,
CellPoint.x, CellPoint.y, this/*pWnd*/);
The prblem was that I should ude "this" not the child window "pWnd".
Re: OnContextMenu in a doc/view
Quote:
Originally Posted by witte
pContextMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON,
CellPoint.x, CellPoint.y, this/*pWnd*/);
this means ur View otherwise use this
Code:
CWnd* pWndPopupOwner = this;
pContextMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON,
CellPoint.x, CellPoint.y, pWndPopupOwner );