Objective Grid: Sending notifications to the parent dialog

Article ID: 529
Last updated: 16 Apr, 2018
Article ID: 529
Last updated: 16 Apr, 2018
Revision: 3
Views: 39100
Posted: 09 Jan, 2001
by Meltreger B.
Updated: 16 Apr, 2018
by Meltreger B.

Problem


What are the steps to make the grid send notifications to its parent dialog? I have placed a grid in a dialog and would like the dialog to capture the grid's double-click event (and others as well).


Cause



Action


Here are some steps:

Define your own message in a header:

// Custom Objective Grid Messages
#define OG_LBUTTONCLK 01

Override corresponding Objective Grid method:

protected:
virtual BOOL OnLButtonClickedRowCol(ROWCOL nRow, ROWCOL nCol, UINT nFlags, CPoint pt);

In CPP send a message to the parent dialog:

// Get a pointer to the parent dialog (works
// also if grid is embedded in a record
// info window)
CDialog* GetParentDialog(CWnd* pWnd)
{
return (CDialog*) GXGetParentWnd(this, RUNTIME_CLASS(CDialog), TRUE);
}

BOOL CGXObGrid::OnLButtonClickedRowCol(ROWCOL nRow, ROWCOL nCol, UINT nFlags, CPoint pt)
{
#ifndef _WIN32

GetParentDialog(this)->SendMessage(WM_COMMAND, GetDlgCtrlID(), MAKELONG(m_hWnd, OG_LBUTTONCLK));
#else
GetParentDialog(this)->SendMessage(WM_COMMAND, MAKELONG(GetDlgCtrlID(), OG_LBUTTONCLK), (LPARAM) m_hWnd );
#endif
return TRUE;
}

In dialog message map, something like this:

ON_CONTROL(OG_LBUTTONDBLCLK, IDC_YOURGRID, OnOGLButtonDblClk)

Do whatever you need to do in the function.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 529
Last updated: 16 Apr, 2018
Revision: 3
Views: 39100
Posted: 09 Jan, 2001 by Meltreger B.
Updated: 16 Apr, 2018 by Meltreger B.

Others in this category