Click here to Skip to main content
13,044,927 members (44,378 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have a mfc- sdi program.i parse my view to 3 subview by static splitter and in one of the views i created a child frame to have a dockable toolbar on it.
there is my codes:

1.this is how i create the child frame:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
	// TODO: Add your specialized code here and/or call the base class
if(!m_wndSpMain.CreateStatic(this, 2, 1, WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST)){
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
if(!m_wndSpMain.CreateView(0, 0, RUNTIME_CLASS(COutputView), CSize(100, 100), pContext)){
TRACE0("Failed to create first pane\n");
return FALSE;
if(!m_wndSpSub.CreateStatic(&m_wndSpMain, 1, 2,WS_CHILD | WS_VISIBLE, m_wndSpMain.IdFromRowCol(1, 0))){
TRACE0("Failed to create nested splitter\n");
return FALSE;
if(!m_wndSpSub.CreateView(0, 0, RUNTIME_CLASS(CTab), CSize(200, 0), pContext)){
TRACE0("Failed to create second pane\n");
return FALSE;
//the most important codes are here:
pContext->m_pNewViewClass = RUNTIME_CLASS(CMainView);
if(!m_wndSpSub.CreateView(0, 1, RUNTIME_CLASS(CmainSPFrame), CSize(0, 0), pContext)){
TRACE0("Failed to create third pane\n");
return FALSE;
	return TRUE;//CFrameWndEx::OnCreateClient(lpcs, pContext);

as u can see i have a Cview class (CMainview) on my child frame (CmainSPFrame).

2.and this is how i create context menu on my CMainview class:

add context menu to App
void CLedMatrixAnimatorApp::PreLoadState()
GetContextMenuManager()->AddMenu(_T("First View menu"), IDR_FIRSTVIEW);

add context menu to view
void CMainView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
	                                              point.x, point.y, this);

now this is my problem:
after i add menu handlers to my CMainView class,seems no ON_COMMAND message is send to veiw and all of the menu items are still gray, is there somthin missing?

sorry for my bad english,and hope u answer my question.
best regards - D rasool
Posted 5-Mar-13 20:19pm
Updated 6-Mar-13 1:40am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

the items are disabled if the menu item are gray.

Check the defines and message handlers in the "this" class.
d rasool 6-Mar-13 3:26am
sorry im new to windows programming would you explain a bit more?
KarstenK 6-Mar-13 6:02am
look in the resource if the items are disabled or via code.

Check that the #define values have everytime a unique value.
d rasool 6-Mar-13 7:27am
many thanx for helping me
d rasool 6-Mar-13 7:22am
#defines r ok and item resources are enable.
i should tell u one more thing:
when i add this menu items to a tool bar(add toolbar buttons with menuitem's id's) on this view i can hit buttons and nothing is wrong!
i mean toolbars work fine and only contextmenu items are gray.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

thnx karstenk for reply.
i solve the problem.when add contextmenu to view :
	                            point.x, point.y, this, TRUE);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 6 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100