Browse by category:
|| | ||
I have derived a class from CGXEditControl and added a message handler for WM_CHAR messages. However, I am not able see the first character entered by the user. What is necessary to process the first character?
This behavior is related to the "active" state of a cell. When you navigate through the grid with arrow keys the Objective Grid positions the current cell into new cells but does not activate these cells. That means the focus will stay with the grid. The grid draws the current cell static with a black frame around the cell.
Because the grid still has the focus any subsequent keyboard message are sent to the grid and not to the edit control. Suppose the user presses a character. This will result in a WM_CHAR message that is sent to the grid. The grid processes this WM_CHAR message and calls CGXGridCore::ProcessKeys and CGXGridCore::OnGridChar. CGXGridCore::ProcessKeys notifies the current cell (the edit control) by calling CGXControl::OnGridChar. The default implementation of this method in the edit control is to set the cell active, replace the cell text with the pressed character and position the edit window in the cell. After the edit cell has been set active all subsequent keyboard messages are sent directly to the CEdit window.
This has the following impact: When you want to process all characters for an edit cell, you have to override both the OnGridChar method and add a message handler for WM_CHAR message. The first key pressed in an edit cell will result in a call to OnGridChar. Subsequent keyboard messages will result in WM_CHAR messages.
OnGridKeyDown and WM_KEYDOWN behave exactly the same way.
The reason for this specific behavior is performance. It is much faster to draw cells static instead of showing and activating the edit window every time the user navigates through the grid with arrow keys. There is another related note on navigating through the grid and redrawing the current cell.
See also: "When navigating through the grid with arrows keys, the new current cell is not refreshed."
|Objective Grid: Printing worksheets from CGXTabWnd||Objective Grid: Decreasing flicker for a grid in a CView|