Popup Menu Items Greyed / Disabled
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=1941
Printed Date: 23 November 2024 at 8:02am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Popup Menu Items Greyed / Disabled
Posted By: djtompa
Subject: Popup Menu Items Greyed / Disabled
Date Posted: 09 March 2005 at 10:42am
I 've created a CXTMenu m_mymenu which I want to display.
CXTPCommandBars::TrackPopupMenu(m_mymenu,NULL, p.x, p.y, m_myview);
Using above command the menu displays correctly, but all entries are grey. This only happens if I use on-the-fly-generated ids in AppendMenu(...). If ids from e.g. the ToolBar are used everything works fine. What's the problem?
|
Replies:
Posted By: Oleg
Date Posted: 10 March 2005 at 9:57am
use TPM_NONOTIFY flag.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: djtompa
Date Posted: 14 March 2005 at 7:41am
Short and Simple :-)
Thank you!
|
Posted By: BruceW
Date Posted: 05 April 2006 at 2:04pm
Hi,
I experience the same problem, even after setting TPM_NO_NOTIFY. My code is as follows:
......
// get a pointer to the application window.
CXTPMDIFrameWnd* pMainWnd = DYNAMIC_DOWNCAST(CXTPMDIFrameWnd, AfxGetMainWnd());
// get a pointer to the CXTPCommandBars object.
CXTPCommandBars* pCommandBars = pMainWnd->GetCommandBars();
UINT nReturn = CXTPCommandBars::TrackPopupMenu(
&popupMenu, TPM_NONOTIFY | TPM_RECURSE | TPM_RETURNCMD, ptCursor.x,
ptCursor.y, pMainWnd, 0, 0, pCommandBars );
The CMenu has been created completely dynamically with the entries
having the appropriate MF_GRAYED flag. It works if I use the
standard TrackPopupMenu, but not with CXTPCommandBars.
I am using a recently downloaded evaluation version.
Am I doing something wrong?
All help appreciated.
Thanks,
Bruce.
|
Posted By: Oleg
Date Posted: 05 April 2006 at 3:08pm
Yes, sorry, it does'n load this flag.
II recommend you build directly CXTPPopupBar/CXTPControl objects instead CMenu and convret it in TrackPopupMenu:
sample:
CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(pCommandBars);
pPopupBar->GetControls()->Add(xtpControlButton);
...
pControl->SetEnabled(FALSE);
..
pControl->SetChecked(TRUE);
...
CXTPCommandBars::TrackPopupMenu(pPopupBar...)
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: BruceW
Date Posted: 06 April 2006 at 6:54am
Hi,
Looking at the various examples and the online help, I tried a different approach, as follows (sample)
void
CMDISampleView::OnRButtonDown(UINT nFlags, CPoint point)
{
CMenu menu;
menu.CreatePopupMenu();
menu.AppendMenu( MF_GRAYED, 1, "Entry" );
menu.AppendMenu( MF_SEPARATOR );
menu.AppendMenu( MF_GRAYED, 1, "Entry" );
CMenu submenu;
submenu.CreatePopupMenu();
submenu.AppendMenu( MF_GRAYED, 1, "Entry" );
submenu.AppendMenu( MF_SEPARATOR );
submenu.AppendMenu( MF_ENABLED | MF_CHECKED, 1, "Entry" );
menu.AppendMenu( MF_STRING | MF_POPUP | MF_ENABLED,
(UINT)submenu.m_hMenu,
"Sub1" );
CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(0);
pPopupBar->LoadMenu( &menu );
POINT ptCursor;
CWinApp* pApp = AfxGetApp();
::GetCursorPos(&ptCursor);
UINT nReturn = CXTPCommandBars::TrackPopupMenu(
pPopupBar, TPM_NONOTIFY| TPM_RETURNCMD, ptCursor.x, ptCursor.y,
AfxGetMainWnd() );
}
This works fine in my small sample example. However when I do the
same in my main application (loading my CMenu the same way) it does not
work. They grayed items are not shown.
Is there some condition / size limit / other flags / etc. I am missing.
Thanks,
Bruce.
|
Posted By: Oleg
Date Posted: 06 April 2006 at 7:49am
Hello,
as I wrote - "pPopupBar->LoadMenu" don't load state of items.
don't use pPopupBar->LoadMenu( &menu ); and create all CXTPPopupBar dynamically.
CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(0); pControl->pPopupBar->GetControls()->Add(xtpControlB utton, 1);
pControl->SetCaption(..).
pConttrol->SetEnabled(..);
etc.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: BruceW
Date Posted: 06 April 2006 at 9:04am
Hi,
I understand that, however it DOES work in my small example above, but not in "real life".
Is it possible to get icons to the labels where the icons are not in a resource file, and thus don't have an Id?
Thanks,
Bruce.
|
Posted By: Oleg
Date Posted: 06 April 2006 at 9:40am
Attach project in issuetrack and we will find problem.
Call pControl->SetIconId(xx) to set item icon.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: BruceW
Date Posted: 06 April 2006 at 9:46am
Hi,
Will reproduce it in a small example project and load that up.
Thanks,
Bruce.
Re Icon, since there are no Ids I think I will have to use SetCustomIcon.
|
|