Objective Grid: Duplicate control IDs

Article ID: 363
Last updated: 27 Apr, 2018
Article ID: 363
Last updated: 27 Apr, 2018
Revision: 3
Views: 1851
Posted: 11 Jan, 2001
by Meltreger B.
Updated: 27 Apr, 2018
by Meltreger B.

Problem

 


Could you please tell me what those window IDs are used for that are passed to CGXEditControl::CreateControl() and the other CreateControl methods for the other cell types? Is there a problem if I use the same ID for multiple cell types?

 

 


Cause

 


99% of the time, this makes no difference because the grid is not using these window control IDs at all. But, I found that the control ID can be essential when you have owner-drawn combo boxes or list boxes because MFC will use the control ID to determine the combo box or list box object for calling OnDrawItem(), OnMeasureItem(), etc. (CGXTabbedComboBox and CGXTabbedComboBoxWnd are owner-drawn combo boxes and list boxes, for example).

Objective Grid itself ignores the control ID. When CGXGridCore::DoCtlColor() is called, only one cell (the current cell) can be active and fire notifications to the parent window. Therefore Objective Grid has no problems determining which window has sent that notification.

 

 


Action

 


So, what I recommend is:

Instead of using a random number, use the control ID that is also used in CGXStyle::SetControl().

Example:
 

// default edit box
pControl = new CGXEditControl(pGrid, GX_IDS_CTRL_EDIT);
break;

// combobox allows user to input any text
pControl = new CGXComboBox(pGrid, GX_IDS_CTRL_COMBOBOX, GX_IDS_CTRL_COMBOBOX, GXCOMBO_NOTEXTFIT);
break;

// combobox uses an integer as cell value
pControl = new CGXComboBox(pGrid, GX_IDS_CTRL_ONEBASED, GX_IDS_CTRL_ONEBASED, GXCOMBO_ONEBASED);

...

With CGXComboBox, don't worry about using the same ID twice in the call to the constructor.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 363
Last updated: 27 Apr, 2018
Revision: 3
Views: 1851
Posted: 11 Jan, 2001 by Meltreger B.
Updated: 27 Apr, 2018 by Meltreger B.

Others in this category