Print Page | Close Window

Left/Right Mouse Click notification on ReportCntrl

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=13761
Printed Date: 11 May 2024 at 11:23am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Left/Right Mouse Click notification on ReportCntrl
Posted By: poiser
Subject: Left/Right Mouse Click notification on ReportCntrl
Date 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?



Replies:
Posted By: SMaton
Date 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


Posted By: Bart6
Date 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


Posted By: znakeeye
Date Posted: 11 May 2009 at 3:14am
ON_WM_CONTEXTMENU()?

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


Posted By: Bart6
Date 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)


Posted By: znakeeye
Date 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/


Posted By: Bart6
Date 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


Posted By: znakeeye
Date 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/


Posted By: mdoubson
Date 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());

}

 



-------------
Mark Doubson, Ph.D.



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