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 » Expanding happens for outer cell with short text Collapse All
Subject Author Date
Suhai Gyorgy Aug 29, 2007 - 3:11 PM

I’ve used __EGBS_EX_CELL_EXPANDING_OUTER style for my grid, but the expanding happens even if the text in the outer cell is short enough to entirely fit the cell. I also reproduced this in ProfUIS_Controls sample’s grid page.

Please check this issue. Thank you!

Technical Support Sep 3, 2007 - 10:11 AM

We are sorry for the delay with this reply. To fix the expanding behavior of the outer header cells, please update the source code for the CExtGridCell::OnInitExpandWnd() method:

bool CExtGridCell::OnInitExpandWnd(
      CExtGridWnd & wndGrid,
      const CExtGridHitTestInfo & htInfo,
      CExtContentExpandWnd & wndContentExpand,
      const RECT & rcExpand,
      INT nSizeOfExpandShadow
      )
{
      ASSERT_VALID( this );
      ASSERT_VALID( (&wndGrid) );
      ASSERT( ! htInfo.IsHoverEmpty() );
      ASSERT( htInfo.IsValidRect() );
      ASSERT( nSizeOfExpandShadow >= 0 );
      rcExpand;
      if(         (GetStyleEx()&__EGCS_EX_UNDEFINED_ROLE) != 0 
            ||    IsEmpty()
            )
            return false;
      if( wndGrid.GetSafeInplaceActiveHwnd() != NULL )
            return false;
      if(         (htInfo.m_dwAreaFlags&__EGBWA_CELL_TEXT) == 0
            ||    htInfo.m_rcPart.IsRectEmpty()
            )
            return false;
INT nSizeOfDynamicShadow = 0;
      if( wndContentExpand.m_ctrlShadow.IsAvailable() )
      {
            nSizeOfDynamicShadow = nSizeOfExpandShadow;
            nSizeOfExpandShadow = 0;
      }
CRect rcExpandInit( 0, 0, 0, 0 );
      { // block for CDC
            CClientDC dc( (CWnd*)&wndGrid );
            INT nColType = htInfo.GetInnerOuterTypeOfColumn();
            INT nRowType = htInfo.GetInnerOuterTypeOfRow();
            CSize sizeCellMeasured =
                  MeasureCell(
                        &wndGrid,
                        dc,
                        htInfo.m_nVisibleColNo,
                        htInfo.m_nVisibleRowNo,
                        htInfo.m_nColNo,
                        htInfo.m_nRowNo,
                        nColType,
                        nRowType
                        );
            CSize sizeCellReal = htInfo.m_rcItem.Size();
            if(         sizeCellReal.cx >= sizeCellMeasured.cx
                  &&    sizeCellReal.cy >= sizeCellMeasured.cy
                  )
                  return false;
            CSize sizeReqiredForText =
                  OnMeasureTextSize(
                        wndGrid,
                        dc,
                        htInfo.m_nVisibleColNo,
                        htInfo.m_nVisibleRowNo,
                        htInfo.m_nColNo,
                        htInfo.m_nRowNo,
                        nColType,
                        nRowType,
                        htInfo.m_rcExtra,
                        htInfo.m_rcItem,
                        htInfo.m_rcPart,
                        htInfo.m_dwAreaFlags
                        );
            CSize sizeCellText = htInfo.m_rcPart.Size();
            UINT nDrawTextFlagsReal =
                  OnQueryDrawTextFlags(
                        htInfo.m_nVisibleColNo,
                        htInfo.m_nVisibleRowNo,
                        htInfo.m_nColNo,
                        htInfo.m_nRowNo,
                        nColType,
                        nRowType,
                        htInfo.m_dwAreaFlags,
                        0
                        );
            
            if( (nDrawTextFlagsReal&DT_RIGHT) != 0 )
            {
                  rcExpandInit.SetRect(
                        htInfo.m_rcPart.right - sizeReqiredForText.cx,
                        htInfo.m_rcPart.top,
                        htInfo.m_rcPart.right,
                        htInfo.m_rcPart.top + sizeReqiredForText.cy
                        );
            } // if( (nDrawTextFlagsReal&DT_RIGHT) != 0 )
            else
            {
                  rcExpandInit.SetRect(
                        htInfo.m_rcPart.left,
                        htInfo.m_rcPart.top,
                        htInfo.m_rcPart.left + sizeReqiredForText.cx,
                        htInfo.m_rcPart.top + sizeReqiredForText.cy
                        );
                  if( (nDrawTextFlagsReal&DT_CENTER) != 0 )
                  {
                        rcExpandInit.OffsetRect(
                              ( htInfo.m_rcPart.Width() - rcExpandInit.Width() ) / 2,
                              0
                              );
                  } // if( (nDrawTextFlagsReal&DT_CENTER) != 0 )
            } // else from if( (nDrawTextFlagsReal&DT_RIGHT) != 0 )
            if( (nDrawTextFlagsReal&DT_BOTTOM) != 0 )
            {
                  rcExpandInit.OffsetRect(
                        0,
                        ( htInfo.m_rcPart.Height() - rcExpandInit.Height() )
                        );
            } // if( (nDrawTextFlagsReal&DT_BOTTOM) != 0 )
            else if( (nDrawTextFlagsReal&DT_VCENTER) != 0 )
            {
                  rcExpandInit.OffsetRect(
                        0,
                        ( htInfo.m_rcPart.Height() - rcExpandInit.Height() ) / 2
                        );
            } // else if( (nDrawTextFlagsReal&DT_VCENTER) != 0 )
            if(         sizeCellText.cx >= sizeReqiredForText.cx
                  &&    sizeCellText.cy >= sizeReqiredForText.cy
                  )
            {
                  CRect rcClient = wndGrid.OnSwGetClientRect();
                  if(         rcExpandInit.bottom <= rcClient.bottom
                        &&    rcExpandInit.top >= rcClient.top
                        &&    rcExpandInit.right <= rcClient.right
                        &&    rcExpandInit.left >= rcClient.left
                        )
                        return false;
            }
//          rcExpandInit.SetRect(
//                htInfo.m_rcPart.left,
//                rcExpand.top,
//                htInfo.m_rcPart.left + sizeReqiredForText.cx,
//                rcExpand.bottom
//                );
//          if( rcExpandInit.Height() < sizeReqiredForText.cy )
//                rcExpandInit.bottom = rcExpandInit.top + sizeReqiredForText.cy;
            rcExpandInit.InflateRect(
                  __EXT_EXPANDED_TEXT_GAP_X,
                  __EXT_EXPANDED_TEXT_GAP_Y
                  );
            rcExpandInit.InflateRect(
                  0,
                  0,
                  nSizeOfExpandShadow,
                  nSizeOfExpandShadow
                  );
            wndGrid.ClientToScreen( &rcExpandInit );
            rcExpandInit =
                  CExtPaintManager::stat_AlignWndRectToMonitor(
                        rcExpandInit,
                        false,
                        true
                        );
            wndGrid.ScreenToClient( &rcExpandInit );
      } // block for CDC
      ASSERT( !rcExpandInit.IsRectEmpty() );

bool bRetVal =
            wndContentExpand.Activate(
                  rcExpandInit,
                  &wndGrid,
                  __ECWAF_DEF_EXPANDED_ITEM_PAINTER
                        |__ECWAF_DRAW_SOURCE
                        |__ECWAF_NO_CAPTURE
                        |__ECWAF_REDIRECT_MOUSE
                        |__ECWAF_REDIRECT_NO_DEACTIVATE
                        |__ECWAF_REDIRECT_AND_HANDLE
                        |__ECWAF_HANDLE_MOUSE_ACTIVATE
                        |__ECWAF_MA_NOACTIVATE
                  );
      if( nSizeOfDynamicShadow && wndContentExpand.GetSafeHwnd() != NULL )
            wndContentExpand.m_ctrlShadow.Create( wndContentExpand.m_hWnd, nSizeOfDynamicShadow );
      return bRetVal;
}
Thank you.