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 General Discussion » How to avoid gap left/right of CExtGridCellPicture bitmap? Collapse All
Subject Author Date
Christian Gross Jul 20, 2009 - 7:06 PM

Hello Prof-UIS team,


i’m using ImageModeSet() to stretch or tile a CExtBitmap object assigned with LoadBMP_Resource() to the cell. Vertically the image touches the borders but not horizontally. There seems to be a 2 pixel gap left and right of the image. How can this gap be removed?


Thanks & regards,


Chris

Chris G. Jul 21, 2009 - 1:08 PM

Thank you, the fix now works for stretched images. But for tiled ones there still exist the same gaps.


Regards,


Chris

Technical Support Jul 22, 2009 - 12:48 PM

We assume the stretched mode is special. The gaps or borders can be useful because the show selection background and/or focus rectangle.

Technical Support Jul 21, 2009 - 8:51 AM

Thank you for reporting this issue. We fixed it in the following method:

void CExtGridCellPictureBase::OnPaintText(
      const RECT & rcCellText,
      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 );
      if( ! dc.RectVisible( &rcCellText ) )
            return;
      wndGrid; nVisibleColNo; nVisibleRowNo; nColNo; nRowNo; nColType; nRowType; rcCellExtra; rcCell; rcVisibleRange; dwAreaFlags; dwHelperPaintFlags;
      if( IsInvisible() || IsUndefined() || IsEmpty() )
            return;
const CExtBitmap * pBmpBuffer = BitmapGetBuffer();
      if( pBmpBuffer == NULL || pBmpBuffer->IsEmpty() )
            return;
      if( ( dwHelperPaintFlags & __EGCPF_SIMPLIFIED_RENDERING_TARGET ) != 0 )
      {
            CRect rcX( rcCellExtra );
            CExtMemoryDC dcX( &dc, &rcX );
            OnPaintText( rcCellText, wndGrid, dcX, nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType, rcCellExtra, rcCell, rcVisibleRange, dwAreaFlags, dwHelperPaintFlags&(~__EGCPF_SIMPLIFIED_RENDERING_TARGET) );
            return;
      }
bool bSmootherAsPossible = true;
      if( m_eImageMode == eStretch )
      {
            CRect rcStretch = rcCellText;
            rcStretch.InflateRect( 2, 0 );
            pBmpBuffer->AlphaBlendSkinParts( dc.GetSafeHdc(), rcStretch, CRect(0,0,0,0), CExtBitmap::__EDM_STRETCH, true, bSmootherAsPossible );
      }
      else if( m_eImageMode == eTile )
            pBmpBuffer->AlphaBlendSkinParts(  dc.GetSafeHdc(), rcCellText, CRect(0,0,0,0), CExtBitmap::__EDM_TILE, true, bSmootherAsPossible );
      else if( m_eImageMode == eAlign )
      {
            CSize szSize = pBmpBuffer->GetSize();
            CRect rcDst( rcCellText.left, rcCellText.top, rcCellText.left + szSize.cx, rcCellText.top + szSize.cy );
            DWORD dwCellStyle = GetStyle();
            switch( (dwCellStyle&__EGCS_TA_HORZ_MASK) )
            {
            case __EGCS_TA_HORZ_BY_TYPE:
            case __EGCS_TA_HORZ_LEFT:
            break;
            case __EGCS_TA_HORZ_RIGHT:
                  rcDst.OffsetRect( rcCellText.right - rcDst.right, 0 );
            break;
            case __EGCS_TA_HORZ_CENTER:
                  rcDst.OffsetRect( ( (rcCellText.right - rcCellText.left) - (rcDst.right - rcDst.left) ) / 2, 0 );
            break;
#ifdef _DEBUG
            default:
                  ASSERT( FALSE );
            break;
#endif // _DEBUG
            }
            switch( (dwCellStyle&__EGCS_TA_VERT_MASK) )
            {
            case __EGCS_TA_VERT_BY_TYPE:
            case __EGCS_TA_VERT_TOP:
            break;
            case __EGCS_TA_VERT_BOTTOM:
                  rcDst.OffsetRect( 0, rcCellText.bottom - rcDst.bottom );
            break;
            case __EGCS_TA_VERT_MIDDLE:
                  rcDst.OffsetRect( 0, ( (rcCellText.bottom - rcCellText.top) - (rcDst.bottom - rcDst.top) ) / 2 );
            break;
#ifdef _DEBUG
            default:
                  ASSERT( FALSE );
            break;
#endif // _DEBUG
            }
            CRect rcSrc( 0, 0, szSize.cx, szSize.cy );
            rcDst.top = max( rcDst.top, rcCellText.top );
            rcDst.left = max( rcDst.left, rcCellText.left );
            rcDst.bottom = min( rcDst.bottom, rcCellText.bottom );
            rcDst.right = min( rcDst.right, rcCellText.right );
            if( ::RectVisible( dc.GetSafeHdc(), &rcDst ) )
            {
                  INT nOldStretchBltMode = bSmootherAsPossible ? ( ::GetStretchBltMode( dc.m_hDC ) ) : ( COLORONCOLOR ) ;
                  if( bSmootherAsPossible )
                        ::SetStretchBltMode( dc.m_hDC, ( g_PaintManager.m_bIsWinNT ) ? HALFTONE : COLORONCOLOR );
                  pBmpBuffer->AlphaBlend( dc.m_hDC, rcDst, rcSrc );
                  if( bSmootherAsPossible )
                        ::SetStretchBltMode( dc.m_hDC, nOldStretchBltMode );
            }
      }
}