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 » CExtWndShadow drawing problems Collapse All
Subject Author Date
David Coleman Jun 24, 2005 - 3:13 AM

Hello,


I have successfully created a function to change the text colour of a grid cell.
However, this interferes with the drawing of the CExtContentExpandWnd and makes the text the wrong colour.
The way I am attempting to get round this is to override the OnPaintExpandedContent function and implement
my own drawing for the CExtContentExpandWnd. This is working well apart from the drawing of the shadow.
It is only drawing a one pixel high line at the bottom of the main rectangle.
Please refer to the code below and explain where I am going wrong.



 virtual bool OnPaintExpandedContent(
  CExtContentExpandWnd::PAINT_ITEM_CONTENT_DATA & picd,
  const CExtGridWnd & wndGrid,
  const CExtGridHitTestInfo & htInfo,
  CExtContentExpandWnd & wndContentExpand,
  INT nSizeOfExpandShadow
  ) const
 {
  // create font
  CFont m_Font;
  LOGFONT* m_pLF;
  m_pLF=(LOGFONT*)calloc(1,sizeof(LOGFONT));
  strncpy(m_pLF->lfFaceName,"Tahoma",31);
  m_pLF->lfHeight=13;
  m_pLF->lfWeight=500;
  m_pLF->lfItalic=0;
  m_pLF->lfUnderline=0;
  m_Font.CreateFontIndirect(m_pLF);
 
  // draw CExtContentExpandWnd
  
  picd.m_dc.FillSolidRect(picd.m_rcItem.left, picd.m_rcItem.top, picd.m_rcItem.Width()-nSizeOfExpandShadow, picd.m_rcItem.Height()-nSizeOfExpandShadow, RGB(0,0,0));
  picd.m_dc.FillSolidRect(picd.m_rcItem.left+1, picd.m_rcItem.top+1, picd.m_rcItem.Width()-2-nSizeOfExpandShadow, picd.m_rcItem.Height()-2-nSizeOfExpandShadow, RGB(255,255,225));
  
  picd.m_dc.SelectObject(m_Font);
  picd.m_dc.SetTextColor(RGB(0,0,0));
  picd.m_dc.TextOut(2, 2, m_strData);


  free(m_pLF);
  
  // draw shadow


  CRect rc1stArea, rc2ndArea;


  rc1stArea = CRect::CRect(0,0,0,0);
  rc2ndArea = CRect::CRect(0,0,0,0);


  CExtWndShadow wndShadow;
  //wndShadow.Restore(picd.m_dc);
  wndShadow.Paint(
   picd.m_dc,
   picd.m_rcItem,
   &rc1stArea,
   &rc2ndArea,
   nSizeOfExpandShadow
   );
  
  return true;
 }
 


Regards,
David.

Technical Support Jun 24, 2005 - 7:21 AM

To change the text color in a grid cell, just override CExtGridCell::OnQueryTextColor() and return the desired COLORREF value. This is enough to see the custom text color both in the grid cell inside the grid window and in the pop-up content expand window because the same paint methods of the CExtGridCell class are used in both cases. You don’t have to code custom painting for the content expand window.

As for the source code published in your message: please do not create your own font. Just use the font returned by the CExtGridCell::OnQueryCellFont() method. We guess this should fix the one pixel size conflict.