I am doing some validation in OnValidate().  OnValidate() is being called when there is a WM_KILLFOCUS message for the control. This works fine, right up until the moment that the user hits the Cancel button on a CDialog.  How do I avoid validation when the user hits cancel?

Calling OnValidate from a WM_KILLFOCUS message handler is not correct because there is no way to detect what kind of button the user has clicked on.

What you should do when you are using the grid in dialogs is:

a)Call DDV_GXGridWnd in DoDataExchange

b)Whenever grid data should be validated, call UpdateData().

In OnOK UpdateData is called by default but if you want to validate the grid whenever you click on another control in your dialog, you should create a notification that another control has gained focus and then call UpdateData(). This will update the grid and will also be able to set back the focus to the grid.