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.
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:
Create a new class with ClassWizard. Use "generic CWnd" as the Class Type.
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:
Create a new class with ClassWizard. Use "CView" as Class Type.
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.
Change the generated OnDraw(), OnBeginPrinting(), and OnEndPrinting() methods to call the base-class CGXGridView version.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.