Dapfor home  

Notifications

The grid is capable to inform its owners about some events. For example about an addition of a new line, selection or focus changes, etc. The given information is sent in the form of WM_NOTIFY message where one of the structures, containing the detailed information about an event is stored in the lParam. For increasing the grid productivity it is possible to block sending events by call of CGrid::AllowNotifications() function.

List of available notifications:

The next example demonstrates how to get notications from the grid

1. You have a class that contains the GGrid object

//File SomeDialog.h

using namespace Dapfor;
class CSomeDialog : public CDialog
{
...
protected:
    afx_msg void OnSelectionChanged(NMHDR*, LRESULT*);
    afx_msg void OnExpansionChanged(NMHDR*, LRESULT*);

private:
    GUI::CGrid m_Grid;
}; 


  
//File SomeDialog.cpp
BEGIN_MESSAGE_MAP(CSomeDialog, CDialog)
    ...
    ON_NOTIFY(Dapfor::GUI::Notifications::SelectionChanged, IDC_CUSTOM1, OnSelectionChanged)
    ON_NOTIFY(Dapfor::GUI::Notifications::ExpansionChanged, IDC_CUSTOM1, OnExpansionChanged)
END_MESSAGE_MAP()

void CSomeDialog::OnSelectionChanged(NMHDR* hdr, LRESULT* lresult)
{
    Dapfor::GUI::NM_GRIDITEM* item = (Dapfor::GUI::NM_GRIDITEM*)hdr;
    //Your implementation...
}
  
void CSomeDialog::OnExpansionChanged(NMHDR* hdr, LRESULT* lresult)
{
    Dapfor::GUI::NM_GRIDITEM* item = (Dapfor::GUI::NM_GRIDITEM*)hdr;
    //Your implementation...
}

2. If you have your own control that derives from the grid, you can use the next:

//File CustomGrid.h
#include <Dapfor/GUI/Grid.h>

class CCustomGrid : public Dapfor::GUI::CGrid
{
protected:
    afx_msg void OnLButtonDown(UINT flags, CPoint point);
    afx_msg void OnExpansionChanged(NMHDR*, LRESULT*);

    DECLARE_MESSAGE_MAP()
};


//File CustomGrid.cpp
#include <Dapfor/GUI/Notifications.h>

BEGIN_MESSAGE_MAP(CCustomGrid, Dapfor::GUI::CGrid)
    ON_WM_LBUTTONDOWN()
    ON_NOTIFY_REFLECT(Dapfor::GUI::Notifications::ExpansionChanged, OnExpansionChanged)
END_MESSAGE_MAP()

void CCustomGrid::OnLButtonDown(UINT flags, CPoint point)
{
    //Don't forget to call the method of the base class
    CGrid::OnLButtonDown(flags, point);
}
  
void CCustomGrid::OnExpansionChanged(NMHDR* hdr, LRESULT* lresult)
{
    Dapfor::GUI::NM_GRIDITEM* item = (Dapfor::GUI::NM_GRIDITEM*)hdr;
    ...
} 

Copyright Dapfor 2007-2009
Generated on Sat Jan 30 15:01:23 2010 for MFCGrid by doxygen 1.5.5