Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Left/Right Mouse Click notification on ReportCntrl
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Left/Right Mouse Click notification on ReportCntrl

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

Joined: 23 October 2007
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote poiser Quote  Post ReplyReply Direct Link To This Post Topic: Left/Right Mouse Click notification on ReportCntrl
    Posted: 23 March 2009 at 11:29am
Currenty I only get a Left/Right ButtonClick notification when a report item is clicked using this code:
 ON_NOTIFY( NM_RCLICK,  XTP_ID_REPORT_CONTROL, OnReportItemRClick)

How can I get mouse event notifications if any area on the report control is clicked (i.e not just report records/items).

Example: A report with only one record has a lot of empty space. Right-clicking on this empty space does not generate a mouse event. How can I get it to do so. Why is is that mouse events (left/right button click) are generated only when you right-click an item?
Back to Top
SMaton View Drop Down
Groupie
Groupie


Joined: 04 May 2009
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote SMaton Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2009 at 6:37am
Hi,

is there a solution to this? I'm currently looking into this, too, but I haven't found a solution yet.

Thanks,
Stefan
Back to Top
Bart6 View Drop Down
Groupie
Groupie
Avatar

Joined: 22 March 2009
Location: Belgium
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bart6 Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2009 at 4:39pm
Hi all,

Same here. i'm looking for the behaviour i get with XTP_NM_REPORT_LBUTTONDOWN, but then for the right mouse button.

Bart
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: 11 May 2009 at 3:14am
ON_WM_CONTEXTMENU()?
PokerMemento - http://www.pokermemento.com/
Back to Top
Bart6 View Drop Down
Groupie
Groupie
Avatar

Joined: 22 March 2009
Location: Belgium
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bart6 Quote  Post ReplyReply Direct Link To This Post Posted: 11 May 2009 at 3:48am
No, ON_WM_CONTEXTMENU would work on the Dialog, not the ReportControl. We need a notification message of the right mouse button; but which one? (The ReportControl header file only mentions LBUTTONDOWN)
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: 11 May 2009 at 11:19am
Not true.
 
You derive from CXTPReportControl and add a handler for WM_CONTEXTMENU.
 
void CReportControlEx::OnContextMenu(CWnd* pWnd, CPoint pos)
{
 BOOL menuHandled = FALSE;
 
 CPoint clientPos = pos;
 ScreenToClient(&clientPos);
 
 CXTPReportColumn *pColumn = GetReportHeader()->HitTest(clientPos);
 if (pColumn)
  menuHandled = ShowHeaderMenu(pColumn, pos);
 else if (HitTest(clientPos))
  menuHandled = ShowItemMenu(pos);
 
 if (!menuHandled)
  CXTPReportControl::OnContextMenu(pWnd, pos);
}
PokerMemento - http://www.pokermemento.com/
Back to Top
Bart6 View Drop Down
Groupie
Groupie
Avatar

Joined: 22 March 2009
Location: Belgium
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bart6 Quote  Post ReplyReply Direct Link To This Post Posted: 11 May 2009 at 1:34pm
I was assuming not deriving from ReportCntrl - but you are correct, it does work when deriving. Thanks for the reaction.

->Would be nice if it would work without deriving OOTB. Codejock?

Bart
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: 17 May 2009 at 6:26pm
Have to agree here. All this hit-testing should live inside the framework!
PokerMemento - http://www.pokermemento.com/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 2009 at 12:37am

ON_NOTIFY(NM_CLICK, XTP_ID_REPORT_CONTROL, OnReportItemClick)

works for any left or both (left + right) button click.
e.g.

void CVirtualListView::OnReportItemClick(NMHDR * pNotifyStruct, LRESULT * /*result*/) {

CXTPReportControl& wndReport = GetReportCtrl();

XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct;

if (!pItemNotify->pColumn)

return;

if (!pItemNotify->pRow){

//do smth with columns - e.g. organize special sort

}

}

else if (m_bAllowDelete && GetAsyncKeyState(VK_RBUTTON) > 0)

{

if (AfxMessageBox(_T("Do you want to delete this record?"), MB_YESNO) == IDYES)

{

//I use it to delete record if both button used
int ind = pItemNotify->pRow->GetIndex();

CDBVListSet* pSet = &GetDocument()->m_dBVListSet;

int nRecordCount = pSet->GetRecordCount();

pSet->MoveFirst();

pSet->Move(ind);

pSet->Delete();

GetReportCtrl().SetVirtualMode(new CVirtualRecord(pSet), nRecordCount - 1, 7);

GetReportCtrl().Populate();

}

}

//if (!pItemNotify->pRow)

// return;

//TRACE(_T("Click on row %d, col %d\n"),

// pItemNotify->pRow->GetIndex(), pItemNotify->pColumn->GetItemIndex());

}

 

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.