<< Return to Main Index

< Return to Class Index

CGXGridCore::RegisterControl

void RegisterControl(WORD nID, CGXControl* pControl, BOOL bDefault = FALSE, BOOL bShowInStyleSheet = TRUE);

nID

Specifies a unique ID for the control. This ID should be a string-resource-id. The string-resource should contain the name of the control to be displayed in the control-listbox of the control-page in the style-sheet.

pControl

Points to the control to be registered. The control can be any class derived from CGXControl.

bDefault

Specifies if the default control should be set to this control. Only one control can be the default control.

bShowInStyleSheet

TRUE if the control shall be shown in the control’s page in the CGXStyleSheet. FALSE if it should not be shown.

Remarks

Registers the CGXControl-object associated with a unique control-id.

If the id is already associated with a control-object, the previous control object will be destroyed and replaced with the new control-object.

Default Ids defined in GXRES.RC are:

GX_IDS_CTRL_EDIT        "Edit Control"
GX_IDS_CTRL_STATIC      "Static Text"
GX_IDS_CTRL_PUSHBTN     "Pushbutton"
GX_IDS_CTRL_RADIOBTN    "Radio Buttons"
GX_IDS_CTRL_CHECKBOX    "Checkbox, 1/0"
GX_IDS_CTRL_COMBOBOX    "ComboBox, no text-fit"
GX_IDS_CTRL_HOTSPOT     "Hotspot Edit"
GX_IDS_CTRL_SPINEDIT    "Spin Edit"
GX_IDS_CTRL_HEADER      "Header"
GX_IDS_CTRL_SCROLLEDIT  "Edit Control, Scrollbar"
GX_IDS_CTRL_LISTBOX     "Listbox"
GX_IDS_CTRL_CHECKBOX3D  "Checkbox, 3d-Effect"
GX_IDS_CTRL_RADIOBTN3D  "Radio Buttons, 3d-Effect"
GX_IDS_CTRL_ZEROBASED   "ComboBox, zero-based"
GX_IDS_CTRL_ONEBASED    "ComboBox, one-based"
GX_IDS_CTRL_TEXTFIT     "ComboBox, text-fit"
GX_IDS_CTRL_CBS_DROPDOWN "MFC ComboBox"
GX_IDS_CTRL_CBS_DROPDOWNLIST "MFC DropDownList"
GX_IDS_CTRL_ONEBASED_EX "Combo, disp.choice, 1-base"
GX_IDS_CTRL_ZEROBASED_EX "Combo, disp.choice, 0-base"
GX_IDS_CTRL_BROWSEARROWHEADER "Row Header"
GX_IDS_CTRL_RICHEDIT    "Rich Edit"
GX_IDS_CTRL_MASKEDIT    "Masked Edit"
GX_IDS_CTRL_PROGRESS    "Progressbar"
GX_IDS_CTRL_PASSWORD    "Password Edit"
GX_IDS_CTRL_CBS_TABBED_DROPDOWN "Tabbed MFC ComboBox"
GX_IDS_CTRL_CBS_TABBED_DROPDOWNLIST "Tabbed MFC DropDownList"
GX_IDS_CTRL_TABBED_COMBOBOX "Tabbed ComboBox"
GX_IDS_CTRL_CHECKLIST_COMBOBOX "Dropdown CheckListBox"
GX_IDS_CTRL_DATETIME    "Date Time Control with popup calendar"
GX_IDS_CTRL_DATETIMENOCAL "Date time control without calendar"
GX_IDS_CTRL_CURRENCY    "Currency control"

All of the above controls can be used automatically in the grid, because when you assign one of the above controls to a cell, GetRegisteredControl will instantiate and register the control automatically. GetRegisteredControl will call CGXAbstractControlFactory::CreateControl to create the control object. Take also a look at the Control Factory Wizard. This lets you define what cell types should be available in your application. See the section "Reducing the size of your application" in the User's Guide for more details.

To change the default behavior of these controls, you can subclass them and reassign an instance of the subclassed control by calling RegisterControl in OnInitialUpdate.

Take a look at the file GXCTRLI.H. This file contains all standard controls. You can create any control you like with these classes and use it in the grid.

Note:

All registered control instances will be deleted by Objective Grid when the grid object is deleted.

Example

This example illustrates how to register a bitmap as user-defined control. The user can assign this bitmap to any cell in the grid through the control-page of the style-sheet.

// Your .RC - file:

STRINGTABLE DISCARDABLE
BEGIN
    IDS_CTRL_BITMAP        "Welcome bitmap"
END

// Your .CPP - file:

...

void CGridSampleView::OnInitialUpdate( )
{
   ...

   RegisterControl(IDS_CTRL_BITMAP,
      new CGXBitmapButton(this, IDB_WELCOME));

   if (bFirstView /* new doc */)
   {
      // Display the welcome bitmap
      SetCoveredCellsRowCol(3, 2, 15, 6);
      SetStyleRange(CGXRange( 3, 2 ), CGXStyle( )
         .SetControl( IDS_CTRL_BITMAP ));
   }

   ...
}

See Also

CGXGridCore::GetControl CGXGridCore::GetRegisteredControl CGXAbstractControlFactory::CreateControl

CGXGridCore

Class Overview | Class Members