Click here to Skip to main content
15,920,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have a dialog base app (vc++ 6.0) with menu bar (that load top of dialog). I want to change enable or disable menu item or check mark items, use bellow code for change menu items:
C++
//////////////////
// .h
afx_msg void OnUpdateUIRange(CCmdUI* pCmdUI);

// .cpp
BEGIN_MESSAGE_MAP(CSUDlg, CDialog)
...
ON_UPDATE_COMMAND_UI_RANGE(ID_MENU_RESET_ERR, ID_MENU_SET_CONFIG, OnUpdateUIRange)
...
END_MESSAGE_MAP()

void CSUDlg::OnUpdateUIRange(CCmdUI* pCmdUI)
{
	if ( !m_bInit )
		return;
	switch (pCmdUI->m_nID)
	{
	case ID_MENU_SET_CONFIG:
		if (m_bSocketConnection || m_bConnect)
			pCmdUI->Enable(FALSE);
		else
			pCmdUI->Enable(TRUE);
		pCmdUI->SetCheck(TRUE);
		break;
	}
}

//////////////////

But it is not working until I click menu and then click 1 item and then call back "OnUpdateUIRange" function, and any change on selected item. (but in MDI app I see all of times this function called.)

Please help me ... :confused:
Posted
Updated 20-Nov-10 23:05pm
v3
Comments
Sandeep Mewara 16-Nov-10 11:10am    
Use PRE tags to format code part. It makes the question readable.

1 solution

An CFrameWnd object does iterate all popup menu items and then update them explicitly (see its reaction for the WM_INITPOPUPMENU message)...

...and an CDialog object does not.

So you could implement an own reaction for your CSUDlg class :)
 
Share this answer
 

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


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