Print Page | Close Window

How to enable menu item on popup?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=3039
Printed Date: 28 May 2025 at 5:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to enable menu item on popup?
Posted By: jeffcmj
Subject: How to enable menu item on popup?
Date Posted: 15 October 2005 at 7:40am

Hi, I use the following code to show a popup menu

int nID = CXTPCommandBars::TrackPopupMenu(&menu, TPM_RIGHTBUTTON|TPM_RECURSE|TPM_RETURNCMD, pt.x, pt.y, AfxGetMainWnd(),NULL,NULL,pBars);

My question is the menu items are all disabled, since I don't have a command handler. With MFC I can disable CMainFrame::m_bAutoMenuEnable to have them enabled, but with XTP, it does not work.

Please advise.

Thanks

Jeff




Replies:
Posted By: jeffcmj
Date Posted: 16 October 2005 at 8:53am
I solve it myself by adding TPM_NONOTIFY flag.


Posted By: umcbrad
Date Posted: 19 December 2005 at 9:36am

I would like some help with this problem also....menus is always grayed out...I can't seem to fix it...

As usual, it seems to work in the examples, but I can't see why...

I am trying to invoke it is the view of an MDI app.  Here is my code

void CVanGoghView::OnRButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 
 CScrollView::OnRButtonDown(nFlags, point);

 ClientToScreen(&point);
 CMenu mnu;
 mnu.LoadMenu(IDR_RCLICK_OBJECT);
 //owner window is set to 'this', which means it gets the WM_COMMAND messages...
 CXTPCommandBars::TrackPopupMenu(&mnu, TPM_RIGHTBUTTON , point.x, point.y, this, 0, 0, gpTheVGMainFrm->GetCommandBars());
}

 

thanks,

 

Brad



Posted By: umcbrad
Date Posted: 19 December 2005 at 9:40am

I also tried this, and it doesn't work...

CMenu mnu;
 mnu.LoadMenu(IDR_RCLICK_OBJECT);
 mnu.EnableMenuItem(ID_OBJECT_LINK_LABEL, TRUE);
 //owner window is set to 'this', which means it gets the WM_COMMAND messages...
 CXTPCommandBars::TrackPopupMenu(&mnu, TPM_RIGHTBUTTON , point.x, point.y, this, 0, 0, gpTheVGMainFrm->GetCommandBars());



Posted By: jeffcmj
Date Posted: 19 December 2005 at 10:56am
You shall have a command handler for the grayed command.


Posted By: umcbrad
Date Posted: 19 December 2005 at 10:56am
ah, yes...I was overlooking that...thanks for the help!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net