![]() |
ContextMenu in Report Control.... |
Post Reply ![]() |
Author | |
ddlittle ![]() Senior Member ![]() Joined: 19 February 2004 Location: United States Status: Offline Points: 132 |
![]() ![]() ![]() ![]() ![]() 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
|
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1201 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
ddlittle ![]() Senior Member ![]() Joined: 19 February 2004 Location: United States Status: Offline Points: 132 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1201 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
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/
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |