Print Page | Close Window

CXTPPropertyGridItemColor and No Fill

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=861
Printed Date: 23 November 2024 at 9:38pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPropertyGridItemColor and No Fill
Posted By: AliRafiee
Subject: CXTPPropertyGridItemColor and No Fill
Date Posted: 18 June 2004 at 10:01am

I am trying to use a CXTPPropertyGridItemColor for a fill color property.  In the OnInplaceButtonDown method I create a CXTColorPopup derived class with the CPS_XT_NOFILL style.  Within that class I catch the CPN_XT_SELNOFILL message. Here is where I am having problems. What value would I set the CXTPPropertyGridItemColor's value to in order for the grid item to display a no color indicator?

Thanks

Ali




Replies:
Posted By: AliRafiee
Date Posted: 18 June 2004 at 12:03pm

I ended up modifing CXTPPropertyGridItemColor in order to solve the problem. If anyone knows a better way please let me know.

Ali

I have defined No fill as 0xFFFFFFFF, and made the following changes:

//Draw a box with an X for No Fill

BOOL CXTPPropertyGridItemColor::OnDrawItemValue(CDC& dc, CRect rcValue)
{
   COLORREF clr = GetColor();
   CRect rcSample(rcValue.left - 2, rcValue.top + 1, rcValue.left + 18, rcValue.bottom);
   if (clr == 0xFFFFFFFF)
   {
      CXTPPenDC pen(dc, RGB(0,0,0));
      dc.Rectangle(rcSample);
      dc.MoveTo(rcSample.left+1,rcSample.top+1);
      dc.LineTo(rcSample.right-1,rcSample.bottom-1);
      dc.MoveTo(rcSample.right-1,rcSample.top+1);
      dc.LineTo(rcSample.left+1,rcSample.bottom-1);
   }
   else
   {
      CXTPPenDC pen(dc, clr);
      CXTPBrushDC brush(dc, m_clrValue);
      dc.Rectangle(rcSample);
   }
 
   CRect rcText(rcValue);
   rcText.left += 25;

   dc.DrawText( m_strValue, rcText,  DT_SINGLELINE|DT_VCENTER);

   return TRUE;
}


COLORREF CXTPPropertyGridItemColor::StringToRGB(CString str)

   if (str.CompareNoCase("no fill") == 0)
   {
      return 0xFFFFFFFF;
   }

   CString strRed, strGreen, strBlue;
 
   AfxExtractSubString(strRed, str, 0, ';');
   AfxExtractSubString(strGreen, str, 1, ';');
   AfxExtractSubString(strBlue, str, 2, ';');

   return RGB(__min(_ttoi(strRed), 255), __min(_ttoi(strGreen), 255), __min(_ttoi(strBlue), 255));
}

CString CXTPPropertyGridItemColor::RGBToString(COLORREF clr)
{
   if (clr == 0xFFFFFFFF)
   {
      return "No Fill";
   }

   CString str;
   str.Format(_T("%i; %i; %i"), GetRValue(clr), GetGValue(clr), GetBValue(clr));
   return str;
}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net