-
January 7th, 2006, 05:48 PM
#1
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?
-
January 7th, 2006, 07:01 PM
#2
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 ).
Please use code tags [code] [/code]
We would change the world, but God won't give us the sourcecode..
Undocumented futures are fun and useful....
_________
Gili
-
January 9th, 2006, 02:56 PM
#3
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
"Live only for tomorrow, and you will have a lot of empty yesterdays today."
-
January 9th, 2006, 05:00 PM
#4
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".
-
January 9th, 2006, 11:21 PM
#5
Re: OnContextMenu in a doc/view
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 );
If I Helped You, "Rate This Post"
Thanks
Guna
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|