changing bargraph colors

I have the following code section:

void TestGraph::OnShow()
{
  int a, b, c, d;

  in = fopen("teststring.dat", "rb");
  fread(bars, 30, 1, in);
  fclose(in);
  CRect cr;
  CBrush blk(RGB(0,0,0));
  GetDlgItem(IDC_PICU1)->GetClientRect(cr);
  CWnd* pWnd=GetDlgItem(IDC_PICU1);
  d = (cr.Width()/30);
  pControlDC=pWnd->GetDC();
  pControlDC->SelectObject(blk);
  c=10;
  for (b=0; b<30; b++)
  {
    a = ((bars[b+0x30]*10)/14) + 1;
    pControlDC->Rectangle (c, cr.Height(), c+2, cr.Height()-a);
    c+=d;
  }
}

The file teststring.dat contains 30 bytes data in the range of 00 to FF
This routine draws a bargraph of my data in the PICU1 box just fine.

How do I change the color of the bars???
I have tried different values of CBrush with no luck.
Please direct me in the right path.
Thanks


0
eddie331 (70)
9/8/2006 12:47:31 AM
vc.mfc 33608 articles. 0 followers. Follow

11 Replies
690 Views

Similar Articles

[PageSpeed] 51

Ed wrote:
> I have the following code section:
>
> void TestGraph::OnShow()
> {
>   int a, b, c, d;
>
>   in = fopen("teststring.dat", "rb");
>   fread(bars, 30, 1, in);
>   fclose(in);
>   CRect cr;
>   CBrush blk(RGB(0,0,0));
>   GetDlgItem(IDC_PICU1)->GetClientRect(cr);
>   CWnd* pWnd=GetDlgItem(IDC_PICU1);
>   d = (cr.Width()/30);
>   pControlDC=pWnd->GetDC();
>   pControlDC->SelectObject(blk);
>   c=10;
>   for (b=0; b<30; b++)
>   {
>     a = ((bars[b+0x30]*10)/14) + 1;
>     pControlDC->Rectangle (c, cr.Height(), c+2, cr.Height()-a);
>     c+=d;
>   }
> }
>
> The file teststring.dat contains 30 bytes data in the range of 00 to FF
> This routine draws a bargraph of my data in the PICU1 box just fine.
>
> How do I change the color of the bars???
> I have tried different values of CBrush with no luck.
> Please direct me in the right path.


What control is IDC_PICU1? If its a any of common controls (with the
exception of CButton), you should not  paint the color yourself.
Instead let the control take care of the painting. Typically controls
will respond to OnCtlColor and you provide a brush of your choice. It
will then do the painting itself. You should approach it that way.

---
Ajay

0
ajaykalra (6842)
9/8/2006 1:58:58 AM
IDC_PICU1 is a picture box in which I draw my bargraph.


"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
news:1157680738.376655.70660@b28g2000cwb.googlegroups.com...
>
> Ed wrote:
>> I have the following code section:
>>
>> void TestGraph::OnShow()
>> {
>>   int a, b, c, d;
>>
>>   in = fopen("teststring.dat", "rb");
>>   fread(bars, 30, 1, in);
>>   fclose(in);
>>   CRect cr;
>>   CBrush blk(RGB(0,0,0));
>>   GetDlgItem(IDC_PICU1)->GetClientRect(cr);
>>   CWnd* pWnd=GetDlgItem(IDC_PICU1);
>>   d = (cr.Width()/30);
>>   pControlDC=pWnd->GetDC();
>>   pControlDC->SelectObject(blk);
>>   c=10;
>>   for (b=0; b<30; b++)
>>   {
>>     a = ((bars[b]*10)/14) + 1;
>>     pControlDC->Rectangle (c, cr.Height(), c+2, cr.Height()-a);
>>     c+=d;
>>   }
>> }
>>
>> The file teststring.dat contains 30 bytes data in the range of 00 to FF
>> This routine draws a bargraph of my data in the PICU1 box just fine.
>>
>> How do I change the color of the bars???
>> I have tried different values of CBrush with no luck.
>> Please direct me in the right path.
>
>
> What control is IDC_PICU1? If its a any of common controls (with the
> exception of CButton), you should not  paint the color yourself.
> Instead let the control take care of the painting. Typically controls
> will respond to OnCtlColor and you provide a brush of your choice. It
> will then do the painting itself. You should approach it that way.
>
> ---
> Ajay
> 


0
eddie331 (70)
9/8/2006 2:35:26 AM


"Ed" <eddie@hvc.rr.com> wrote in message
news:OF4Mg.2254$bz1.1331@trndny09...
> IDC_PICU1 is a picture box in which I draw my bargraph.

Is it a Picture Control in resource edit? If yes, its a CStatic which
responds to OnCtlColor for color changes. If not, what type of control is
it?

--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


0
ajaykalra (6842)
9/8/2006 3:11:27 AM
This is pretty bad code.  In fact, it is really, really awful.  There's about one error
per line.

Where is this being drawn?  Is OnShow called from your OnPaint handler?  If it isn't, this
whole piece of code is nearly useless.

The style is also pretty bad, and you should never "reach inside" a control to draw it as
you do here.  You can pretty much throw this code out, and save some pieces of it for the
correct place

The correct approach is to put the body of this code in a subclassed control (most
commonly a CStatic, for example), as

class CMyControl : public CStatic { // for example, using ClassWizard
     public:
         void SetValues(CByteArray b);
     protected: 
         int units;
         CByteArray values;
};

CMyControl::CMyControl()
   {
   }

void CMyControl::SetValues(CByteArray & b)
    {
     values.SetSize(0);
     values.Copy(b);
     Invalidate();
    }

#define DIM(x)  (sizeof(x) / sizeof((x)[0])

COLORREF barcolors[] = {
      RGB(255, 0, 0),
      RGB(0, 255, 0),
      RGB(0, 0, 255),
      RGB(255, 0, 255),
      RGB(255, 255, 0),
      RGB(0, 255, 255),
      ... more colors until you get bored
};


void CMyControl::OnPaint()
    {
     CPaintDC dc(this);
     CRect r;
     if(b.GetSize() == 0)
         return;  // array of samples is empty
     GetClientRect(&r);
     int dx = cr.Width() / b.GetSize();;
     int leftover = cr.Width() - (dx * b.GetSize());
     // because the width may not be evenly divisible by the number of samples,
     // the sum of samples will not fill in the entire window.  So we compute the
     // "leftover" value which allows us to "stretch" some of the bars to 
     // make sure that we fill the whole area

     int x = 0;

     for(int i = 0; i < b.GetSize(); i++)
         { /* draw each histogram */
          int saved = dc.SaveDC();

          int h = ?;// compute height of histogram here
          int w = dx;
          if(leftover > 0)
              { /* fudge width */
                w++;
                leftover--;
              } /* fudge width */
          CBrush br(barcolors[i % DIM(barcolors)]);
          dc.SelectObject(&br);
          CRect r(x, r.bottom - h, x+w, r.bottom);
          dc.Rectangle(r);
          dc.RestoreDC(saved);
         } /* draw each histogram */
  }
     
You have to make sure the brush is not selected intot he DC when ~CBrush is executed,
hence the SaveDC/RestoreDC calls.

To set the values, do something like

#define NUMBER_OF_SAMPLES 30
CByteArray b;
b.SetSize(NUMBER_OF_SAMPLES);

CFile f;
if(!f.Open(_T("teststring,dat"), CFile::modeRead))
     ... deal with error here
f.Read(b.GetData(), NUMBER_OF_SAMPLES);
f.Close();

c_MyControl.SetValues(b);

Key here is that the ONLY place you can do this drawing is in the OnPaint handler of the
child control (or in some function called from OnPaint).  It *must* have all the
information required to do the drawing, at any arbitrary time, without warning, and it
must be able to redraw the entire window contents.
					joe
----------------------------------------------------------------------------

On Fri, 08 Sep 2006 00:47:31 GMT, "Ed" <eddie@hvc.rr.com> wrote:

>I have the following code section:
>
>void TestGraph::OnShow()
>{
>  int a, b, c, d;
****
Avoid ever using a comma in a declaration list.  If you want four variables, declare them
as
	int a;
	int b;
	int c;
	int d;
of course, with really meaningful names like a,b,c,d it is nearly impossible to figure out
what the code is trying to do.
>
>  in = fopen("teststring.dat", "rb");
>  fread(bars, 30, 1, in);
>  fclose(in);
>  CRect cr;
>  CBrush blk(RGB(0,0,0));
>  GetDlgItem(IDC_PICU1)->GetClientRect(cr);
****
This is wrong; avoid GetDlgItem.  See my essay on Avoiding GetDlgItem.
Do not try to get the rectangle of some internal control from outside itself
****
>  CWnd* pWnd=GetDlgItem(IDC_PICU1);
****
Do not use GetDlgItem
****
>  d = (cr.Width()/30);
****
Do not hardwire 30
****
>  pControlDC=pWnd->GetDC();
****
It is very rare to need to GetDC(); this should be avoided whenever possible.  In the rare
cases you need a DC outside the OnPaint handler, use CClientDC.  Assume that if you write
GetDC() you have made a design error [the few times it will make sense will be obvious;
otherwise just avoid it]
****
>  pControlDC->SelectObject(blk);
****
Do not manipulate the DC of a control from outside the control
****
>  c=10;
****
And what is the magical significance of "10"?
****
>  for (b=0; b<30; b++)
****
30 has appeared several times.  Do not do this.  Use a #define
****
>  {
>    a = ((bars[b+0x30]*10)/14) + 1;
****
What is the significance of magical values like 0x30, 10, 14, and 1?  I can't quite figure
out what you are doing here.  Also, the use of meaningless identifier names like a,b,c,d
makes the code almost totally unintelligible.  Use x, y for horizontal and vertical
positions, dx and dy for delta positions horizontally and vertically, w and h for width
and height, and other similarly useful codes.
****
>    pControlDC->Rectangle (c, cr.Height(), c+2, cr.Height()-a);
****
Do this in the control itself.  I'm so lost trying to reverse-engineer what you are trying
to accomplish that I'm just guessing in my rewrite
****
>    c+=d;
****
If the window width is not an even multiple of the number of samples, you won't fill the
window when you add all these widths up.
>  }
****
I gather you are drawing a histogram, but I can't figure out what way it is going.
****
>}
>
>The file teststring.dat contains 30 bytes data in the range of 00 to FF
>This routine draws a bargraph of my data in the PICU1 box just fine.
>
>How do I change the color of the bars???
****
Do another SelectObject of the brush
>I have tried different values of CBrush with no luck.
>Please direct me in the right path.
>Thanks
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
9/8/2006 3:49:26 AM
Yes, IDC_PICU1 is a picture control.
I have 6 bargraphs I need to display in 6 different areas and I am using 
puicture controls for each
IDC_PICU1, IDCPICU2,.....IDC_PICU6
The routines I am using work just fine but only display's black bars.


"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
news:eq3$5Rv0GHA.4312@TK2MSFTNGP02.phx.gbl...
>
>
>
> "Ed" <eddie@hvc.rr.com> wrote in message
> news:OF4Mg.2254$bz1.1331@trndny09...
>> IDC_PICU1 is a picture box in which I draw my bargraph.
>
> Is it a Picture Control in resource edit? If yes, its a CStatic which
> responds to OnCtlColor for color changes. If not, what type of control is
> it?
>
> --
> Ajay Kalra [MVP - VC++]
> ajaykalra@yahoo.com
>
> 


0
eddie331 (70)
9/8/2006 12:08:08 PM
How do I do this so that I select which Picture control I want the bargraph 
in?

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:7sn1g2lpv4evvngma0pmsgcaqrjvv66292@4ax.com...
> This is pretty bad code.  In fact, it is really, really awful.  There's 
> about one error
> per line.
>
> Where is this being drawn?  Is OnShow called from your OnPaint handler? 
> If it isn't, this
> whole piece of code is nearly useless.
>
> The style is also pretty bad, and you should never "reach inside" a 
> control to draw it as
> you do here.  You can pretty much throw this code out, and save some 
> pieces of it for the
> correct place
>
> The correct approach is to put the body of this code in a subclassed 
> control (most
> commonly a CStatic, for example), as
>
> class CMyControl : public CStatic { // for example, using ClassWizard
>     public:
>         void SetValues(CByteArray b);
>     protected:
>         int units;
>         CByteArray values;
> };
>
> CMyControl::CMyControl()
>   {
>   }
>
> void CMyControl::SetValues(CByteArray & b)
>    {
>     values.SetSize(0);
>     values.Copy(b);
>     Invalidate();
>    }
>
> #define DIM(x)  (sizeof(x) / sizeof((x)[0])
>
> COLORREF barcolors[] = {
>      RGB(255, 0, 0),
>      RGB(0, 255, 0),
>      RGB(0, 0, 255),
>      RGB(255, 0, 255),
>      RGB(255, 255, 0),
>      RGB(0, 255, 255),
>      ... more colors until you get bored
> };
>
>
> void CMyControl::OnPaint()
>    {
>     CPaintDC dc(this);
>     CRect r;
>     if(b.GetSize() == 0)
>         return;  // array of samples is empty
>     GetClientRect(&r);
>     int dx = cr.Width() / b.GetSize();;
>     int leftover = cr.Width() - (dx * b.GetSize());
>     // because the width may not be evenly divisible by the number of 
> samples,
>     // the sum of samples will not fill in the entire window.  So we 
> compute the
>     // "leftover" value which allows us to "stretch" some of the bars to
>     // make sure that we fill the whole area
>
>     int x = 0;
>
>     for(int i = 0; i < b.GetSize(); i++)
>         { /* draw each histogram */
>          int saved = dc.SaveDC();
>
>          int h = ?;// compute height of histogram here
>          int w = dx;
>          if(leftover > 0)
>              { /* fudge width */
>                w++;
>                leftover--;
>              } /* fudge width */
>          CBrush br(barcolors[i % DIM(barcolors)]);
>          dc.SelectObject(&br);
>          CRect r(x, r.bottom - h, x+w, r.bottom);
>          dc.Rectangle(r);
>          dc.RestoreDC(saved);
>         } /* draw each histogram */
>  }
>
> You have to make sure the brush is not selected intot he DC when ~CBrush 
> is executed,
> hence the SaveDC/RestoreDC calls.
>
> To set the values, do something like
>
> #define NUMBER_OF_SAMPLES 30
> CByteArray b;
> b.SetSize(NUMBER_OF_SAMPLES);
>
> CFile f;
> if(!f.Open(_T("teststring,dat"), CFile::modeRead))
>     ... deal with error here
> f.Read(b.GetData(), NUMBER_OF_SAMPLES);
> f.Close();
>
> c_MyControl.SetValues(b);
>
> Key here is that the ONLY place you can do this drawing is in the OnPaint 
> handler of the
> child control (or in some function called from OnPaint).  It *must* have 
> all the
> information required to do the drawing, at any arbitrary time, without 
> warning, and it
> must be able to redraw the entire window contents.
> joe
> ----------------------------------------------------------------------------
>
> On Fri, 08 Sep 2006 00:47:31 GMT, "Ed" <eddie@hvc.rr.com> wrote:
>
>>I have the following code section:
>>
>>void TestGraph::OnShow()
>>{
>>  int a, b, c, d;
> ****
> Avoid ever using a comma in a declaration list.  If you want four 
> variables, declare them
> as
> int a;
> int b;
> int c;
> int d;
> of course, with really meaningful names like a,b,c,d it is nearly 
> impossible to figure out
> what the code is trying to do.
>>
>>  in = fopen("teststring.dat", "rb");
>>  fread(bars, 30, 1, in);
>>  fclose(in);
>>  CRect cr;
>>  CBrush blk(RGB(0,0,0));
>>  GetDlgItem(IDC_PICU1)->GetClientRect(cr);
> ****
> This is wrong; avoid GetDlgItem.  See my essay on Avoiding GetDlgItem.
> Do not try to get the rectangle of some internal control from outside 
> itself
> ****
>>  CWnd* pWnd=GetDlgItem(IDC_PICU1);
> ****
> Do not use GetDlgItem
> ****
>>  d = (cr.Width()/30);
> ****
> Do not hardwire 30
> ****
>>  pControlDC=pWnd->GetDC();
> ****
> It is very rare to need to GetDC(); this should be avoided whenever 
> possible.  In the rare
> cases you need a DC outside the OnPaint handler, use CClientDC.  Assume 
> that if you write
> GetDC() you have made a design error [the few times it will make sense 
> will be obvious;
> otherwise just avoid it]
> ****
>>  pControlDC->SelectObject(blk);
> ****
> Do not manipulate the DC of a control from outside the control
> ****
>>  c=10;
> ****
> And what is the magical significance of "10"?
> ****
>>  for (b=0; b<30; b++)
> ****
> 30 has appeared several times.  Do not do this.  Use a #define
> ****
>>  {
>>    a = ((bars[b+0x30]*10)/14) + 1;
> ****
> What is the significance of magical values like 0x30, 10, 14, and 1?  I 
> can't quite figure
> out what you are doing here.  Also, the use of meaningless identifier 
> names like a,b,c,d
> makes the code almost totally unintelligible.  Use x, y for horizontal and 
> vertical
> positions, dx and dy for delta positions horizontally and vertically, w 
> and h for width
> and height, and other similarly useful codes.
> ****
>>    pControlDC->Rectangle (c, cr.Height(), c+2, cr.Height()-a);
> ****
> Do this in the control itself.  I'm so lost trying to reverse-engineer 
> what you are trying
> to accomplish that I'm just guessing in my rewrite
> ****
>>    c+=d;
> ****
> If the window width is not an even multiple of the number of samples, you 
> won't fill the
> window when you add all these widths up.
>>  }
> ****
> I gather you are drawing a histogram, but I can't figure out what way it 
> is going.
> ****
>>}
>>
>>The file teststring.dat contains 30 bytes data in the range of 00 to FF
>>This routine draws a bargraph of my data in the PICU1 box just fine.
>>
>>How do I change the color of the bars???
> ****
> Do another SelectObject of the brush
>>I have tried different values of CBrush with no luck.
>>Please direct me in the right path.
>>Thanks
>>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 


0
eddie331 (70)
9/8/2006 12:10:15 PM
Ed wrote:
> How do I do this so that I select which Picture control I want the bargraph 
> in?

In Joe's illustration the control is initialized with

c_MyControl.SetValues(b);

If you have several controls you would have several CStatic-derived 
variables like c_MyControl.  You could even have an array of them. Call 
each one with the data it needs. They would all use the same class you 
derive from CStatic, and paint themselves in their OnPaint using the 
data supplied by the SetValues call or the like.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
9/8/2006 1:17:49 PM
> Yes, IDC_PICU1 is a picture control.
> I have 6 bargraphs I need to display in 6 different areas and I am using
> puicture controls for each
> IDC_PICU1, IDCPICU2,.....IDC_PICU6
> The routines I am using work just fine but only display's black bars.
>

You need to write yourself a class which is derived from CStatic and
has methods which change its color. There are several examples
available at codeguru/codeproject. One of these is:
http://www.codeproject.com/staticctrl/coloredit_colorstatic.asp

Once you have this class in your project, subclass each of the
IDC_PICUX in your project and replace the CStatic in your dialog's
header file with above class. They you can change the color at will
based on the functionality provided by the new class.

---
Ajay

0
ajaykalra (6842)
9/8/2006 1:22:39 PM
The reason all the bars were black is because you *drew* all the bars as black!  So it
shouldn't surprise you that they were all black.  If you want multiple colors, then you
have to write code (as I had demonstrated) that selects a different color for each bar.
What I had done was assume you just wanted each bar in a different color and put an array
of colors in.  In one application we actually had the bars go from red to orange, yellow,
green, blue and violet (the spectrum colors) just by changing the values in that table I
illustrated.

Note that to get all this to work you have to bind the controls to class variables of the
CStatic-derived class you created, or they won't get the behavior you want.
					joe

On 8 Sep 2006 06:22:39 -0700, "Ajay Kalra" <ajaykalra@yahoo.com> wrote:

>> Yes, IDC_PICU1 is a picture control.
>> I have 6 bargraphs I need to display in 6 different areas and I am using
>> puicture controls for each
>> IDC_PICU1, IDCPICU2,.....IDC_PICU6
>> The routines I am using work just fine but only display's black bars.
>>
>
>You need to write yourself a class which is derived from CStatic and
>has methods which change its color. There are several examples
>available at codeguru/codeproject. One of these is:
>http://www.codeproject.com/staticctrl/coloredit_colorstatic.asp
>
>Once you have this class in your project, subclass each of the
>IDC_PICUX in your project and replace the CStatic in your dialog's
>header file with above class. They you can change the color at will
>based on the functionality provided by the new class.
>
>---
>Ajay
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
9/8/2006 2:29:45 PM
I got it working thanks to all your help.
Thanks

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:7ev2g2td7013bk9pojv07534tg5b4vosve@4ax.com...
> The reason all the bars were black is because you *drew* all the bars as 
> black!  So it
> shouldn't surprise you that they were all black.  If you want multiple 
> colors, then you
> have to write code (as I had demonstrated) that selects a different color 
> for each bar.
> What I had done was assume you just wanted each bar in a different color 
> and put an array
> of colors in.  In one application we actually had the bars go from red to 
> orange, yellow,
> green, blue and violet (the spectrum colors) just by changing the values 
> in that table I
> illustrated.
>
> Note that to get all this to work you have to bind the controls to class 
> variables of the
> CStatic-derived class you created, or they won't get the behavior you 
> want.
> joe
>
> On 8 Sep 2006 06:22:39 -0700, "Ajay Kalra" <ajaykalra@yahoo.com> wrote:
>
>>> Yes, IDC_PICU1 is a picture control.
>>> I have 6 bargraphs I need to display in 6 different areas and I am using
>>> puicture controls for each
>>> IDC_PICU1, IDCPICU2,.....IDC_PICU6
>>> The routines I am using work just fine but only display's black bars.
>>>
>>
>>You need to write yourself a class which is derived from CStatic and
>>has methods which change its color. There are several examples
>>available at codeguru/codeproject. One of these is:
>>http://www.codeproject.com/staticctrl/coloredit_colorstatic.asp
>>
>>Once you have this class in your project, subclass each of the
>>IDC_PICUX in your project and replace the CStatic in your dialog's
>>header file with above class. They you can change the color at will
>>based on the functionality provided by the new class.
>>
>>---
>>Ajay
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 


0
eddie331 (70)
9/8/2006 4:08:09 PM
I have shown how to write a custom control in my blog recently. Check it 
out.

-- 
Vipin Aravind
http://www.explorewindows.com/Blogs


"Ed" <eddie@hvc.rr.com> wrote in message news:JzgMg.14$SQ1.0@trndny09...
>I got it working thanks to all your help.
> Thanks
>
> "Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
> news:7ev2g2td7013bk9pojv07534tg5b4vosve@4ax.com...
>> The reason all the bars were black is because you *drew* all the bars as 
>> black!  So it
>> shouldn't surprise you that they were all black.  If you want multiple 
>> colors, then you
>> have to write code (as I had demonstrated) that selects a different color 
>> for each bar.
>> What I had done was assume you just wanted each bar in a different color 
>> and put an array
>> of colors in.  In one application we actually had the bars go from red to 
>> orange, yellow,
>> green, blue and violet (the spectrum colors) just by changing the values 
>> in that table I
>> illustrated.
>>
>> Note that to get all this to work you have to bind the controls to class 
>> variables of the
>> CStatic-derived class you created, or they won't get the behavior you 
>> want.
>> joe
>>
>> On 8 Sep 2006 06:22:39 -0700, "Ajay Kalra" <ajaykalra@yahoo.com> wrote:
>>
>>>> Yes, IDC_PICU1 is a picture control.
>>>> I have 6 bargraphs I need to display in 6 different areas and I am 
>>>> using
>>>> puicture controls for each
>>>> IDC_PICU1, IDCPICU2,.....IDC_PICU6
>>>> The routines I am using work just fine but only display's black bars.
>>>>
>>>
>>>You need to write yourself a class which is derived from CStatic and
>>>has methods which change its color. There are several examples
>>>available at codeguru/codeproject. One of these is:
>>>http://www.codeproject.com/staticctrl/coloredit_colorstatic.asp
>>>
>>>Once you have this class in your project, subclass each of the
>>>IDC_PICUX in your project and replace the CStatic in your dialog's
>>>header file with above class. They you can change the color at will
>>>based on the functionality provided by the new class.
>>>
>>>---
>>>Ajay
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>
> 


0
vipin (697)
9/8/2006 6:08:15 PM
Reply:

Similar Artilces:

External data link change
Hi, I've a sheet linked to an external data on the net, and I would like that a cell in this sheet to indicate the last date and time it was updated, the simplest way the better but I can do some programming too. Thanks for your attention, -- Domingos Junqueira No need of help any more, I solved the question. Thanks again ...

Why does the change change to a number?
Hi all, I've noticed something wierd and always wondered WHY it happens. When you type a date into a cell, and then change the Formatting of it to a 'general' cell, it turns into a number. How does it come up with that number? What is the significance? i.e. type today's date of "12/7/2007" - change it to a 'General' format, and it then says "39423". I'm a trainer of Excel and this question always comes up. I'm curious myself too. Thanks! Joe It's the number of days since January zero 1900 using Excel default for windows (M...

changing the way Excel displays selected cells
Is there a way to change the way Excel displays selected cells? I'm interested in viewing all the selected cells highlighted (with light blue for instance), but by default excel highlights all the cells but not the first one the same occurs when you define a range with no adyacents cells Your definition of the display is not quite correct. Excel highlights the current cell, Excel also highlights a selecte range. The currently selected cell is generally the first of a range, bu press enter and the current cell changes and becomes the second, the third etc in the range. You cannot...

DST changes for Exchange 5.5
I noticed the 2007 DST Calendar Update "Exchange tool" is available now: http://support.microsoft.com/kb/930879 This will seemingly take care of calendars for mailboxes still on Exchange 5.5 servers, as Exchange 5.5 is listed as "compatible" . However would this address the CDO issues such as BlackBerry users and OWA users still on Exchange 5.5 ? Thanks in advance, Itrcb4 On Mon, 12 Feb 2007 14:31:00 -0800, itrcb4 <itrcb4@discussions.microsoft.com> wrote: >I noticed the 2007 DST Calendar Update "Exchange tool" is available now: > >http://su...

Track Changes
How do i remove the track changes in outlook? When i press "Enter", a symbol that represents "Enter" will appears. Same for space etc. ...

more on VBA function name change
I thought I'd start a new thread since I haven't received any replies to my first one... To recap: I've declared a function in a module using mixed case: Function TMDE_Category (FormName As Form) I noticed recently that it appeared in the module as Function tmde_category(FormName As Form) I changed it back to the mixed case declaration, saved the module, exited the app, reopened it and looked. The function had changed back to the all lowercase declaration. Things I've tried since the original post: Using the databse documenter, I selected all ob...

Can't Publish changes with Deploy Manager
After a migration process, I can't publish the changes made on CRM. When I try do this in Deploy Manager I get the follow error: ---------------------------------------------------------------------------- ----- Publish done with errors. See the event log to get deitails NETRA-INOVACAO: ***Error*** Failed to download XSL template files from Web Server ---------------------------------------------------------------------------- ----- Can somebody help me? I don't know if the migration process have any relationship with the error. Thank you for pay attention. []'s Vin�cius Pitta...

How to change icon for my application
Hi, I am currently developing an application on visual studio 6.0, and i wish to change the MFC icon on my application header. Anyone can help? Thank you. Raed Sawalha wrote: > Hi, I am currently developing an application on visual studio 6.0, and i > wish to change the MFC icon on my application header. Anyone can help? Thank > you. > > Open the icon resource for editing by double clicking. Then notice the control just above the editing grid that lets you switch between editing the large icon and editing the small one. -- Scott McPhillips [VC++ MVP] thanx that work...

How to change newsgroup message font
Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? regards "nobody" wrote in message news:EWTao.39493$GF5.7129@hurricane... > Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? Newsgroup messages are usually plain text. The font used is that selected at [no name tab] > Options > Mail > Read > Fonts for the encoding specified for the messag...

Notify change of email address when changing ISP
How do I notify my entire address book of an email address when I change ISP's? Thanks By sending a mail to everyone ? If you do so, please use BCC for the adresses, this way you won't spread everybody's e-mail adres to everybody. Niels Bob Baker wrote: > How do I notify my entire address book of an email address when I change ISP's? > Thanks ...

Change a formula to an acual number
I want to change the formula I have created to the number it has created Example: Cell A1 is the number 1. Cell A2 is the formula =a1+1 creatin the number 2. I want this to be a two not a formula. Any ideas? Laura, copy, then paste special, valves -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Laura" <anonymous@discussions.microsoft.com> wrote in message news...

How do I use cond format formula to set cell text and color?
Using MS Excel 2003: As and example, I entered into Conditional Format for cell B1: "Formula is", IF(A1="","Test",""). For true condition, the format is set to fill Yellow and font color red. I'm expecting cell B1 to display, "Test" in red text with yellow background when A1 is blank, but it does not work. No errors are displayed. Any ideas? in my experience you can only set the format,you cant have the word test show up.Apply the format condition only using =A1="" and put a seperate if statement in the cell.If it blank ...

Problem Changing an Investment Name
I am trying to change an investment name and Money 2006 tells me "The name or symbol 'TRP Spectrum Income' has already been used for a deleted investment. Please enter a different name." When I go to delete investments the name does not appear! Any ideas on how I get Money to accept the name change? This is the first time I have run into this situation and I have made numerous name changes in Money over the years. In microsoft.public.money, Ken wrote: >I am trying to change an investment name and Money 2006 tells me "The name >or symbol 'TRP Spec...

how do i find color saffron in pub2003
old pub98 had color boxes to choose from now all i get is a color wheel impossible to find a specific color like saffron. please help chefmstobey1968 wrote: > old pub98 had color boxes to choose from now all i get is a color wheel > impossible to find a specific color like saffron. please help Make sure you go to Tools > Options and select Show basic colors in color palette -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com ~pay it forward~ This posting is provided "AS IS" with no warranties, and confers no rights. ...

Should I change this code?
Should I change 556 to 560???..............Thanks for your help..........Bob Private Sub Command560_Click() On Error GoTo Err_Command556_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmClientInfomation" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command556_Click: Exit Sub Err_Command556_Click: MsgBox Err.Description Resume Exit_Command556_Click End Sub On Sun, 15 Jul 2007 16:37:26 +1200, "Bob V" <rjvance@ihug.co.nz> wrote: > >Should I change 556 to 560???..............Thanks for your help.....

How to change default font in Outlook 2003
Can someone tell me how to change tthe default font in Outlook 2003 when composing a new email. It always comes up as Times New Roman. I remember somewhere that I specified that Outlook should use Word as the text editor and that seems to be the case. I have Arial as my default font in Word but this seems to make no difference when using Outlook. Hi, Please go to Tools > Setting > Mail Format > Stationery and Fonts > Fonts It's right there :) On 20 Nov 2005 06:28:45 -0800, amarsarit@gmail.com wrote: >Hi, >Please go to Tools > Setting > Mail Format > Statione...

Appointment colors gone
Hi If one creates an appointment from CRM and gives it a color in Outlook the color dissapears but not when the appointment was created in Outlook, is this a bug ? /Jack ...

icon changes with change of extension
when we change the extension of a file in windows, its icon also changes..... how does windows do tht. in my application i require a similar approach. i want the icon to be dependent on the file extension not on the attributes of the file. i have gone trough the registry but things are not very clear. Windows has listed all the file extensions avaliable there, but there is no general way to extract icons for those extension... kindly help icon changes with change of extension "Neelu" <nemesia31@gmail.com> wrote in message news:1161232739.720722.120950@b28g2000cwb.google...

Field Type Change
I am trying to change a free text field to a drop down menu in my current database, that already has data entered for this particular field, in order to avoid multiple versions of the same organization that are just typed in differently. I'm assuming that I'll need to recode the different versions of an entry to make them uniform but after that, I'm unsure how to proceed so I won't lose any data. Is this possible or will I need to delete the field, recreate it as a drop down and then re-enter the data? Thanks in advance! Mike Thanks everyone for all the input and advice s...

Tracking Changes
I am the author of a document and am making revisions to it. I want to chnage the redline color to denote new edits from the 1st version. Can anyone guide me through this process? I am sure it is easy but I cannot figure it out. THanks Peter On Wed, 10 Feb 2010 07:08:06 -0800, Peter SSI <Peter SSI@discussions.microsoft.com> wrote: >I am the author of a document and am making revisions to it. I want to >chnage the redline color to denote new edits from the 1st version. Can >anyone guide me through this process? I am sure it is easy but I cannot >figure i...

Save Changes? #2
Sometimes, but not always, Excel asks if I want to save the current file, even though I've made no changes. Does anyone know why this occurs, and if there is a setting I can change to avoid the prompt unless actual changes are made? Thank you. Sprinks There are a number of functions that will update themselves when the workbook is opened, and this causes Excel to act as though the workbook has been changed. These functions include NOW() , TODAY(), ROW(), etc. See Volatile Functions in help for more info. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consult...

colour change of dated box
How can I change the colour of a dated box of excel after the date is over. I want the programme to read date automatically from pc and change colour. try Conditional Formatting In 2003: 1. Select the cells you want to format 2. Choose Format, Conditional Formatting 3. Choose Cell Value Is from the first drop down 3. Choose Formula is from the first drop down 4. Choose less than 5. In the third box, enter =TODAY() 6. Click the Format button 7. Choose a color on the Patterns tab (or any available option) 7. Click OK twice. -- Hope this is helpful Appreciate that you provide your feedbac...

Daylight saving time changes for Exchange 2003 server
Hi guys, I was wondering how other real life systems administrators are preparing for the upcoming “2007 global time zone update for Windows” (daylight time change for exchange 2003 server). I'd like to know what contingency plans are being planned out to implement this update and what practical ideas you think thus far are the best. I would greatly value your input. http://www.microsoft.com/windows/timezone/dst2007.mspx -Thanks! ...

changes made but how do I revert !
When I deleted messages they used to dissapear straight away. Now when I delete a message it has a strike through line but the message remains, although it dissapears after I close outlook. I should also add that I use SPAM Inspector but I think this is an Outlook problem caused by some changes. the moral here is change one thing at a time ! Any ideas from anyone. email address required remove to be removed ! Kind regards Nigel Are you using an IMAP account? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.co...

Question about Excel (Office) auditing/changes
I have a document that will need to be posted on a website available for users to download & change/approve. The approval process will not make any changes at all to the document. However, I do need to know they've opened the document. Is there a way to get the name/machine/ip or something regarding who opens a file and when they open it? If so, I would like to do something like that, and either write it to something in the spreadsheet or as an audit trail in a database. If there's no way to do this, I am considering writing a small app that requires them to sign in (somet...