Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Implementation of a CextGridCellButton Collapse All
Subject Author Date
marc uchida Sep 11, 2006 - 2:32 PM

With regards to cells in a CExtGridWnd, I see that you have various implementations of cell types; CExtGridCellString and CExtGridCellCheckBox, for example. I could not find examples or docs refering to a simple button in a grid however.
Do you have such an implementation?
thanks in advance.

Technical Support Sep 12, 2006 - 10:13 AM

Any grid cell supports three built-in buttons: up-down spin button, drop-down button and ellipsis button. You can specify which button should be in the cell using the CExtGridCell::ModifyStyle() method, i.e. you should specify a particular style for this cell: __EGCS_BUTTON_UPDOWN, __EGCS_BUTTON_DROPDOWN and/or __EGCS_BUTTON_ELLIPSIS. The following code enables the ellipsis button for the pCell cell.

      pCell->ModifyStyle( __EGCS_BUTTON_ELLIPSIS, 0L );
Many grid cells perform event handling for these buttons and change their values. But you can implement a custom event handler for the button click event. Create your class derived from CExtGridCell (or any other cell class) and override the following virtual method to catch the button click event:
       virtual void OnButtonPressed(
              CExtGridWnd & wndGrid,
              INT nButtonType,
              const RECT & rcCellExtra,
              const RECT & rcCell,
              LONG nVisibleColNo,
              LONG nVisibleRowNo,
              LONG nColNo,
              LONG nRowNo,
              INT nColType,
              INT nRowType
              );
The nButtonType parameter can be one of the following enumeration constants: CExtGridCell::__EBTT_UPDOWN_UP, CExtGridCell::__EBTT_UPDOWN_DOWN, CExtGridCell::__EBTT_DROPDOWN or CExtGridCell::__EBTT_ELLIPSIS. These constants specify the button type. Please note you can avoid coding your cell classes and handle the button clicks for all the grid cells in your CExtGridWnd-derived class which implements the following virtual method and which should return true if it handles the click event:
       virtual bool OnGridCellButtonPressed(
              CExtGridCell & _cell,
              INT nButtonType,
              const RECT & rcCellExtra,
              const RECT & rcCell,
              LONG nVisibleColNo,
              LONG nVisibleRowNo,
              LONG nColNo,
              LONG nRowNo,
              INT nColType,
              INT nRowType
              );
If you want to change the enabled state of a cell button, you should create a CExtGridCell-derived class and override the following virtual method in it:
       virtual bool OnQueryButtonInfo(
              INT nButtonType,
              bool * p_bEnabled,
              bool * p_bPressed = NULL,
              bool * p_bStayPressed = NULL,
              UINT * p_nTimerElapseValue = NULL
              ) const;
This method is called to query information about the state and behavior of the built-in button specified by the nButtonType parameter.

You can also use a CExtGridCell-derived class for handling clicks on the up and down parts of the spin button and update the enabled state of the up and down buttons independently from each other. This can be done by overriding the following virtual methods:
       virtual bool OnQueryEnabledIncrement() const;
       virtual bool OnQueryEnabledDecrement() const;
       virtual bool OnValueIncrement();
       virtual bool OnValueDecrement();