Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - ContextMenu in Report Control....
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ContextMenu in Report Control....

 Post Reply Post Reply
Author
Message
ddlittle View Drop Down
Senior Member
Senior Member


Joined: 19 February 2004
Location: United States
Status: Offline
Points: 132
Post Options Post Options   Thanks (0) Thanks(0)   Quote ddlittle Quote  Post ReplyReply Direct Link To This Post Topic: ContextMenu in Report Control....
    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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
ddlittle View Drop Down
Senior Member
Senior Member


Joined: 19 February 2004
Location: United States
Status: Offline
Points: 132
Post Options Post Options   Thanks (0) Thanks(0)   Quote ddlittle Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
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.172 seconds.