Print Page | Close Window

ContextMenu in Report Control....

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=14712
Printed Date: 29 September 2024 at 5:25pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: ContextMenu in Report Control....
Posted By: ddlittle
Subject: ContextMenu in Report Control....
Date Posted: 09 July 2009 at 4:52pm
I wanted to implement a context menu in a report control, but can't seem to grab the rbuttondown or wm_contextmenu.  I tried the reportcontrol sample, but there is no right-click menu there, either.
 
any ideas? Thanks!
 
- David



Replies:
Posted By: mgampi
Date Posted: 09 July 2009 at 5:05pm
Hi;

Try this in parent/owner of report control:

ON_NOTIFY(NM_RCLICK, 0, OnReportItemRClick)

void CStateViewEx::OnReportItemRClick(NMHDR * pNotifyStruct, LRESULT* /*result*/)
{
    XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct;
    if (_pGrid->GetRows()->GetCount()==0)
        return;
    CMenu menu;
    VERIFY(menu.LoadMenu(IDR_STATEREPORTCONTROL_POPUP));
    // track menu
    GetCommandBars()->TrackPopupMenuEx(menu.GetSubMenu(0), TPM_LEFTALIGN |TPM_RIGHTBUTTON, pItemNotify->pt.x, pItemNotify->pt.y, this, NULL);
}


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: ddlittle
Date Posted: 09 July 2009 at 6:17pm

Cool.  that makes the menu appear, but it doesn't respond to the WM_COMMAND.  Any idea who might be grabbing that?  I put a ON_COMMAND() handler for the menu choice.

 
thanks!
 
- David


Posted By: mgampi
Date Posted: 09 July 2009 at 6:21pm
Hi;

GetCommandBars()->TrackPopupMenuEx(menu.GetSubMenu(0), TPM_LEFTALIGN |TPM_RIGHTBUTTON, pItemNotify->pt.x, pItemNotify->pt.y, this, NULL);

in above statement this (the parent/owner of the report control receives the command. So you should implement the command handler in this class. If you do not want this, just replace this by a pointer to your desired destination window.


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: znakeeye
Date Posted: 10 July 2009 at 3:14am
In our project, were command routing is a complete mess, I have found this to work flawlessly:
 
GetCommandBars()->TrackPopupMenuEx(menu.GetSubMenu(0), TPM_LEFTALIGN |TPM_RIGHTBUTTON, pItemNotify->pt.x, pItemNotify->pt.y, this, 0, GetOwner());
Where the owner is the main frame. E.g. m_pane.SetOwner(this).


-------------
PokerMemento - http://www.pokermemento.com/



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