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 » Adding button to cell Collapse All
Subject Author Date
Offer Har Dec 24, 2007 - 9:43 AM

Dear Support,

I need to add a button to a numeric cell.
The button should be a normal button with text label, and when pressed I should get a notification for changing some of the cell’s content.

Please advise as to how this can be implemented.

Regards,
Ron.

Technical Support Dec 25, 2007 - 12:26 PM

We are sorry about forgetting ellipsis dots painted as part of the button by the base class method .There is another solution: the CExtGridCellButton class that implements a cell button (see screenshot).The cell button is demonstrated in the ProfUIS_Controls sample (on the Grid page). But you should use it in a standalone grid column. If you do prefer a custom measured and painted ellipsis button, you should use the following method in your grid cell class

void CYourGridCellClass::OnPaintButton(
      const RECT & rcButton, INT nButtonType, bool bPressed, bool bHovered,
      bool bFocused, bool bEnabled, const CExtGridWnd & wndGrid, CDC & dc,
      LONG nVisibleColNo, LONG nVisibleRowNo, LONG nColNo, LONG nRowNo,
      INT nColType, INT nRowType, const RECT & rcCellExtra, const RECT & rcCell,
      const RECT & rcVisibleRange, DWORD dwAreaFlags, DWORD dwHelperPaintFlags
      ) const
{
      ASSERT_VALID( this );
      ASSERT_VALID( (&wndGrid) );
      ASSERT( dc.GetSafeHdc() != NULL );
      nVisibleColNo; nVisibleRowNo; nColNo; nRowNo; nColType; nRowType;
      rcCellExtra; rcCell; rcVisibleRange; dwAreaFlags;
      if( ! dc.RectVisible(&rcButton) )
            return;
      if( nButtonType == INT(__EBTT_ELLIPSIS) )
      {
            CExtPaintManager::PAINTPUSHBUTTONDATA _ppbd(
                  ((CObject*)this), true, rcButton,
                  _T("Your button text here"),
                  NULL, false, bHovered, bPressed, false, bEnabled, true, false, false,
                  CExtPaintManager::__ALIGN_HORIZ_CENTER|CExtPaintManager::__ALIGN_VERT_CENTER,
                  NULL, false, 0, false
                  );
            wndGrid.PmBridge_GetPM()->PaintPushButton( dc, _ppbd );
            return;
      }
      C_BASE_OF_YourGridCellClass::OnPaintButton(
            rcButton, nButtonType, bPressed, bHovered, bFocused, bEnabled, wndGrid, dc,
            nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType,
            rcCellExtra, rcCell, rcVisibleRange, dwAreaFlags, dwHelperPaintFlags
            );
}

Offer Har Dec 26, 2007 - 8:47 AM

Thanks for the quick response.
Works great.

Technical Support Dec 24, 2007 - 10:46 AM

You should create and use a custom grid cell class which implements the following methods:

- CExtGridCell::OnCalcButtonExtent()
- CExtGridCell::OnPaintButton()
- CExtGridCell::OnButtonPressed()

Each grid cell supports 3 built-in buttons: up-down, drop-down and ellipsis. You can show any combination of these buttons in any grid cell by applying the __EGCS_BUTTON_UPDOWN, __EGCS_BUTTON_DROPDOWN and __EGCS_BUTTON_ELLIPSIS grid cell styles. Any of these buttons can be re-measured and re-painted. The CExtGridCell::OnCalcButtonExtent() virtual method allows you to measure the custom button width and should measure the width of the text you are going to display on the button. You can measure the text width using the CExtPaintManager::stat_CalcTextDimension() static method. The CExtGridCell::OnPaintButton() virtual method should paint a button with text. This method can simply invoke the parent class method and paint a centered piece of text over the already painted button image. The CExtGridCell::OnButtonPressed() virtual method is invoked when the button is clicked and released.

Offer Har Dec 24, 2007 - 4:22 PM

Dear Support,

Thanks for the prompt answer.
It works, and works well...

However there is one thing I had to tweak, and maybe there is a better solution - I used the __EGCS_BUTTON_ELLIPSIS style for my custom button, but I didn’t want the ... to be painted. What I did was that in OnPaintButton, before calling the base class implementation, I changed the nButtonType to some dummy value (100 to be exact) - this stopped the base class from drawing the ..., because it did not know what to draw, but the button face itself was painted well.

Is there a better way to prevent the base class from placing the ... on the button?

Thanks,
Ron.