Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Property Grid
  New Posts New Posts RSS Feed - CXTPPropertyGridItemColor and No Fill
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPPropertyGridItemColor and No Fill

 Post Reply Post Reply
Author
Message
AliRafiee View Drop Down
Groupie
Groupie


Joined: 06 May 2004
Status: Offline
Points: 32
Post Options Post Options   Thanks (0) Thanks(0)   Quote AliRafiee Quote  Post ReplyReply Direct Link To This Post Topic: CXTPPropertyGridItemColor and No Fill
    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

Back to Top
AliRafiee View Drop Down
Groupie
Groupie


Joined: 06 May 2004
Status: Offline
Points: 32
Post Options Post Options   Thanks (0) Thanks(0)   Quote AliRafiee Quote  Post ReplyReply Direct Link To This Post 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;
}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.