Objective Grid : PART I User’s Guide : Chapter 5 Using Objective Grid : Deriving a Grid
Deriving a Grid
You should derive from the Objective Grid classes under the following circumstances:
When you need to handle user interface events
When you need to override some functionality
Say that you are using Objective Grid in a dialog. You would use SubclassDlgItem to place a grid window on the dialog. You could then make API calls such as
 
m_WndGrid.SetValueRange(CGXRange().SetCols(1), _T("Test"));
to initialize the grid object. For this case, there is no need to derive from the grid classes.
On the other hand, say that you want to display a message box when the user clicks on a certain cell. There are no APIs that enable the programmer to do this. In order to display the message box, you have to override a grid virtual function OnLButtonHitRowCol(). This requires that you have a derived CGXGridWnd control.
NOTE >> You cannot use ClassWizard to add these virtual functions. The methods are defined in the Objective Grid library, but ClassWizard will not list them as overridable methods. They are nevertheless available. You can usually copy and paste the declaration for the overrides of your choice from the Objective Grid help files.
Another situation that warrants derivation is when you want to handle standard Windows messages.
Two steps are necessary to derive a class from a CGXGridWnd:
1. Create a new class with ClassWizard. Use “generic CWnd” as the Class Type.
2. Next, using a text editor, change the derivation for your window class, in both the .h and .cpp files. All references to CWnd should be replaced by CGXGridWnd.
If you want to derive a class from CGXGridView, use the following steps instead:
1. Create a new class with ClassWizard. Use "CView" as Class Type.
2. Next, using a text editor, change the derivation in your window class, in both the .h and .cpp files. All references to CView should be replaced by CGXGridView.
3. Change the generated OnDraw(), OnBeginPrinting(), and OnEndPrinting() methods to call the base-class CGXGridView version.