Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Popup Menu Items Greyed / Disabled
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Popup Menu Items Greyed / Disabled

 Post Reply Post Reply
Author
Message
djtompa View Drop Down
Newbie
Newbie
Avatar

Joined: 29 November 2004
Location: Germany
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote djtompa Quote  Post ReplyReply Direct Link To This Post Topic: Popup Menu Items Greyed / Disabled
    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?

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2005 at 9:57am
use TPM_NONOTIFY flag.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
djtompa View Drop Down
Newbie
Newbie
Avatar

Joined: 29 November 2004
Location: Germany
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote djtompa Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2005 at 7:41am

Short and Simple :-)

Thank you!

Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.