Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi.
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:
C++
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
C++
void CLedMatrixAnimatorApp::PreLoadState()
{
GetContextMenuManager()->AddMenu(_T("First View menu"), IDR_FIRSTVIEW);
}


add context menu to view
C++
void CMainView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
#ifndef SHARED_HANDLERS

theApp.GetContextMenuManager()->ShowPopupMenu(IDR_FIRSTVIEW,
	                                              point.x, point.y, this);
#endif
}


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
Updated 10-Oct-18 19:52pm
v3

the items are disabled if the menu item are gray.

Check the defines and message handlers in the "this" class.
 
Share this answer
 
Comments
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.
thnx karstenk for reply.
i solve the problem.when add contextmenu to view :
C++
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_FIRSTVIEW,
	                            point.x, point.y, this, TRUE);
 
Share this answer
 
v2
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_FIRSTVIEW,
	                            point.x, point.y, this,TRUE FALSE);


The last parameter is by set as TRUE, this should be FALSE since you want to use the ON_COMMAND macros you defined for your other menu items in the
BEGIN_MESSAGE_MAP
.
 
Share this answer
 
Comments
CHill60 11-Oct-18 4:56am    
OP already stated that the problem was solved and posted the code that they used
Mubeen_D 11-Oct-18 10:36am    
Chil60, people tend to re-visit the page with similar issues. I actually had the same issue above. I discovered, upon some digging, that the solution that was "solved" was not correct. I posted the correction.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900