*fast* change of line color

I need a function to draw a progressive filled rect. computing the
colors is not the problem.

basically i do something like this


COLORREF cr;
CPen pen;
for ( /* walk a variable i thru height */) {
   cr = ComputeColor(crStart, crEnd, ((double)i) / iMax);

pDC->SelectObject(m_pOldPen);
	m_Pen.DeleteObject();
	m_Pen.CreatePen(PS_SOLID, 1, color);
	m_pOldPen = pDC->SelectObject(&m_Pen);

   pDC->SelectObject(pen);
   /* draw the line */
   /* delete pen */
}

0
clqrq (258)
9/6/2007 2:44:17 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
618 Views

Similar Articles

[PageSpeed] 54

".rhavin grobert" <clqrq@yahoo.de> wrote in message 
news:1189089857.702221.197610@19g2000hsx.googlegroups.com...

>I need a function to draw a progressive filled rect. computing the
> colors is not the problem.
> ...

CDC::GradientFill( )

?

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm


0
dave9996 (486)
9/6/2007 3:01:38 PM
In order to get faster you will have to access the bitmap bits and write 
directly to it.

As far as the code below, here are a few changes

CPen Pen;
 for ( /* walk a variable i thru height */) {

   COLORREF cr = ComputeColor(crStart, crEnd, ((double)i) / iMax);

   Pen.CreatePen(PS_SOLID, 1, color);
   CPen *pOldPen = pDC->SelectObject(&Pen);

   /* draw the line */

   pDC->SelectObject(pOldPen);
   Pen.DeleteObject();
}

AliR.


".rhavin grobert" <clqrq@yahoo.de> wrote in message 
news:1189089857.702221.197610@19g2000hsx.googlegroups.com...
>I need a function to draw a progressive filled rect. computing the
> colors is not the problem.
>
> basically i do something like this
>
>
> COLORREF cr;
> CPen pen;
> for ( /* walk a variable i thru height */) {
>   cr = ComputeColor(crStart, crEnd, ((double)i) / iMax);
>
> pDC->SelectObject(m_pOldPen);
> m_Pen.DeleteObject();
> m_Pen.CreatePen(PS_SOLID, 1, color);
> m_pOldPen = pDC->SelectObject(&m_Pen);
>
>   pDC->SelectObject(pen);
>   /* draw the line */
>   /* delete pen */
> }
> 


0
AliR3470 (3236)
9/6/2007 3:01:59 PM
This looks like a good idea:
http://www.codeguru.com/cpp/g-m/bitmap/specialeffects/article.php/c1713/

Instead of drawing a line use the FillSolidRect method.

for ( /* walk a variable i thru height */) {

   COLORREF cr = ComputeColor(crStart, crEnd, ((double)i) / iMax);

   pDC->FillSolidRect(&Rect,cr);
 }

AliR.



"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
news:HDUDi.31910$RX.23485@newssvr11.news.prodigy.net...
> In order to get faster you will have to access the bitmap bits and write 
> directly to it.
>
> As far as the code below, here are a few changes
>
> CPen Pen;
> for ( /* walk a variable i thru height */) {
>
>   COLORREF cr = ComputeColor(crStart, crEnd, ((double)i) / iMax);
>
>   Pen.CreatePen(PS_SOLID, 1, color);
>   CPen *pOldPen = pDC->SelectObject(&Pen);
>
>   /* draw the line */
>
>   pDC->SelectObject(pOldPen);
>   Pen.DeleteObject();
> }
>
> AliR.
>
>
> ".rhavin grobert" <clqrq@yahoo.de> wrote in message 
> news:1189089857.702221.197610@19g2000hsx.googlegroups.com...
>>I need a function to draw a progressive filled rect. computing the
>> colors is not the problem.
>>
>> basically i do something like this
>>
>>
>> COLORREF cr;
>> CPen pen;
>> for ( /* walk a variable i thru height */) {
>>   cr = ComputeColor(crStart, crEnd, ((double)i) / iMax);
>>
>> pDC->SelectObject(m_pOldPen);
>> m_Pen.DeleteObject();
>> m_Pen.CreatePen(PS_SOLID, 1, color);
>> m_pOldPen = pDC->SelectObject(&m_Pen);
>>
>>   pDC->SelectObject(pen);
>>   /* draw the line */
>>   /* delete pen */
>> }
>>
>
> 


0
AliR3470 (3236)
9/6/2007 3:08:39 PM
duh!

AliR.


"David Webber" <dave@musical-dot-demon-dot-co.uk> wrote in message 
news:%23gO6lcJ8HHA.2476@TK2MSFTNGP05.phx.gbl...
>
> ".rhavin grobert" <clqrq@yahoo.de> wrote in message 
> news:1189089857.702221.197610@19g2000hsx.googlegroups.com...
>
>>I need a function to draw a progressive filled rect. computing the
>> colors is not the problem.
>> ...
>
> CDC::GradientFill( )
>
> ?
>
> Dave
> -- 
> David Webber
> Author of 'Mozart the Music Processor'
> http://www.mozart.co.uk
> For discussion/support see
> http://www.mozart.co.uk/mzusers/mailinglist.htm
>
> 


0
AliR3470 (3236)
9/6/2007 3:10:20 PM
On 6 Sep., 17:01, "David Webber" <d...@musical-dot-demon-dot-co.uk>
wrote:
> ".rhavin grobert" <cl...@yahoo.de> wrote in message
>
> news:1189089857.702221.197610@19g2000hsx.googlegroups.com...
>
> >I need a function to draw a progressive filled rect. computing the
> > colors is not the problem.
> > ...
>
> CDC::GradientFill( )

that one, my CDC doesnt have ?!

btw, i this thread was errorpostet (focus while pressing space was on
'send') the full question is '*fast* changing of LineColor' ...

0
clqrq (258)
9/6/2007 4:13:55 PM
If you have an older version of MFC that doesn't have this, you can always call
	::GradientFill((HDC)dc, ...)

for any CDC dc
			joe

On Thu, 06 Sep 2007 09:13:55 -0700, ".rhavin grobert" <clqrq@yahoo.de> wrote:

>On 6 Sep., 17:01, "David Webber" <d...@musical-dot-demon-dot-co.uk>
>wrote:
>> ".rhavin grobert" <cl...@yahoo.de> wrote in message
>>
>> news:1189089857.702221.197610@19g2000hsx.googlegroups.com...
>>
>> >I need a function to draw a progressive filled rect. computing the
>> > colors is not the problem.
>> > ...
>>
>> CDC::GradientFill( )
>
>that one, my CDC doesnt have ?!
>
>btw, i this thread was errorpostet (focus while pressing space was on
>'send') the full question is '*fast* changing of LineColor' ...
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/6/2007 4:19:13 PM
Reply:

Similar Artilces:

Line Chart values appearing at wrong place
Hi, I have some values as below. The max scale is 10. But values for H, G are showing at point 10, though the values are 2.4 & 0.3 etc. What is the problem. Apr May Jun Jul Aug Sep A 0.7 0.7 0.7 0.7 0.7 0.7 B 0.4 0.4 0.4 0.4 0.4 0.4 C 0.0 0.3 0.3 0.3 0.3 0.3 D 4.4 4.4 4.4 4.6 4.6 4.6 E 0.2 0.2 0.2 0.0 0.0 0.0 F 2.0 1.5 1.5 1.5 1.5 1.5 G 0.0 0.3 0.3 0.3 0.3 0.3 H 2.4 2.4 2.4 2.4 2.4 2.4 It seems to be working for me. My data range is =Sheet1!$A$1:$G$9 and the series is organized in rows. For each series the name is in column A and the values are in columns B through G. The Category (X)...

Font colors available
I have a user complaining about having lost most of her font color palette. She used to have 5 rows with a "more colors" and now she has only about 12 colors to choose from. Anyone know how I can get her other colors back? "Glenda" <Glenda@discussions.microsoft.com> wrote in message news:8CB747FC-7F15-4407-83E8-34EE573F8E4B@microsoft.com... >I have a user complaining about having lost most of her font color palette. > She used to have 5 rows with a "more colors" and now she has only about 12 > colors to choose from. Anyone know how...

How do I change column headings fron numbers to letters in excell.
Hi Martin In Excel 2003 and older goto > Tools>Options>Select General Tab>and unselect R1C1 reference Style. HTH John "Martin C" <Martin C@discussions.microsoft.com> wrote in message news:E6BD9C67-19F2-410D-BFCD-5D08516CBC0E@microsoft.com... > Hi John Thanks I run excell 2007 but with your ref to R1C1 reference Style I managed to put things right Many thanks Martin "John" wrote: > Hi Martin > In Excel 2003 and older goto > Tools>Options>Select General Tab>and unselect > R1C1 reference Style. > HTH > John > "...

How do I stop colors from changing the shades in excel
A user is having issues with her spreadsheet and shades changing colors? Any suggestions? Gladys When do the shades change color? Perhaps Conditional Formatting is changing the colors as the data values change? Gord Dibben Excel MVP On Mon, 11 Apr 2005 11:09:01 -0700, Gladys <Gladys@discussions.microsoft.com> wrote: >A user is having issues with her spreadsheet and shades changing colors? Any >suggestions? ...

Can you change only one cell size in a workbook?
No. You can change the width of a column, or the height of a row. And next time, please remember to ask the question in the body of the message, not just in the subject line. And if this is related to charting, it is not clear how. Was this intended for one of the other Excel groups? -- David Biddulph "Becky" <Becky@discussions.microsoft.com> wrote in message news:4A4504F7-4FA9-44C4-A79C-5E67A9E8C169@microsoft.com... > ...

a macro to copy only 2 lines w/i a cell separated by 4 line breaks
Can anyone help me determine how to copy only 2 specific lines from a cell that contains text in 4 lines that is separated using the line break function? Which two lines? You may be better off parsing into 4 cells then picking the two you want Gord Dibben MS Excel MVP On Wed, 14 Apr 2010 15:31:01 -0700, poltpar <poltpar@discussions.microsoft.com> wrote: >Can anyone help me determine how to copy only 2 specific lines from a cell >that contains text in 4 lines that is separated using the line break function? ...

Multiple line charts on the same graph
Let's say that I have 10 columns of data. Column A represents "origination" dates and Column B represents "total revenue" for those dates in Column A. Column C represents other origination dates and Column D represents total revenue for each of those dates in Column C. Etc for Columns E/F, G/H, and I/J. I know how to create a Line Graph for A/B. But how do I create FIVE lines (graphs), each representing A/B, C/D, E/F, G/H, and I/J, respectively, and all appearing on the SAME chart? Thanks! Use a scatter XY chart with lines and setup your data like this (sh...

Change CRM 3.0 Default Font
I use CRM at work and from home, and the font for messages is always Arial at home and Tahoma at work. Is there anywhere to change this? The only difference is that at home I use XP, at work Vista. Steve ...

Chart Lines
I set up my chart and it added vertical lines to my data. I removed the lines but it also removed the horizontal line at the bottom of my chart. This is not appealing to the eye. Is there some way to add back the horizontal line at the "0" (bottom) of my chart but I DO NOT want the vertical lines below the axis. Thanks Yr post is a bit confusing to me so I hope the following answer helps. From what you say I think the vertical lines you refer to are likely the so-called tick marks. Right-click the x-axis and choose Format Axis. On the pattrens tab, select the line to the...

Line Feed XML File
I am using SqlXmlCommandType component to generate an XML file in a VB.net Console Application. Everything ran perfect except one thing. I need to know if there is anyway to make this XML file Line feed file. In other words, I need to put each tag in one line instead of mixing them up. Do I have to create an XSL file to do this transformation, or there is another way on the .net framework to do it? Nader Shahin wrote: > I am using SqlXmlCommandType component to generate an XML file in a VB.net > Console Application. Everything ran perfect except one thing. I need to know > if ...

Changing DEfault Color Pallette
I know how to change color pallettes in specific workbooks, I know ho to copy pallettes from other workbooks, but is there any way to chang the actual default color pallette that comes up every time you ope excel -- bludovic ----------------------------------------------------------------------- bludovico's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1480 View this thread: http://www.excelforum.com/showthread.php?threadid=26639 You would need to do that in a new workbook, and save it as a template Book.xlt in the XLStart directory. -- HTH RP "bludo...

Fill Effects on Fill Color
I am trying to add some Fill Effects to a regular color filled cell which contains text. I can't seem to find where it is possible. I have tried adding a Basic Shape from the Drawing Toolbar and have played with the transparency and fill effects to get the text to show through, but it looks ugly. Is there either a way to have the text entered into the sheet show in front of the drawing object, or add the same fill effects to a regular cell. Thanks - Doug - San Antonio Rugdoody, The only workaround I can think of is to create a textbox and link it to the cell whose value you w...

Custome Colors?
When using textures and effects and things, can you use custom colors? Can you choose what color you want a texture to be? It doesn't seem to let me. Mark - It looks to me like the textures are built in, without the ability to edit them. For most cases where you can use a texture, you can also use a picture fill. You can probably find texture image files all over the internet, and use them instead. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ Mark wrote: > When using textures and ef...

On-Line Quotes #3
Did anybody find a cause or solution to not being able to update quotes in Money 5.0? MS have a bug opened are trying to find a solution. However as the product is so old we may not get a resolution. -- Regards Bob Peel, Microsoft MVP - Money Hints/Tips http://support.microsoft.com/default.aspx?scid=fh;EN-GB;mny UK Wishes/Suggestions mnyukwsh@microsoft.com "da50" <da50@dropzone.com> wrote in message news:122ab01c3f624$71c3d1a0$a001280a@phx.gbl... > Did anybody find a cause or solution to not being able to > update quotes in Money 5.0? ...

CTreeCtrl: Event that indicates that the status of a checkbox has changed
Hi, I have a tree control created with the TVS_CHECKBOXES property. I want to do some processing when the status of one of the checkboxes in the tree changes. Since I couldn't find a notification message that indicates this change, I used the NM_CLICK message with little more than hope. What I found is that this message is sent before the status of the checkbox actually changes, so I'm only one step behind in my quest. So I have the following questions: 1. Is there a message that is sent after the status of the checkbox changes? 2. If I continue using MN_CLICK, is there a way to wait ...

Changing Dates
I am trying to figure out a way to auto-roll the dates on a spreadsheet forward. Basically, what I have is this: A1 B1 C1 D1 09/25 10/01 10/08 10/15 etc... And what I want is for those dates to all roll-forward as they are surpassed, so that on 09/26, the dates will increment one week and show: 10/01 10/08 10/15 10/22 etc, forever. I appreciate any help in sorting this out. ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Far...

is it possible to change print ink color based on cell value?
Is it possible to change print ink color based on value in a cell for a spreadsheet application? Example: If a cell's value is over 250, can I have it print the number in red ink to draw my attention to it?? You can use Conditional Formatting (Format>Conditional Formatting) to test the value and set the font colour accordingly. -- HTH RP (remove nothere from the email address if mailing direct) "Dave The Mechanic" <Dave The Mechanic@discussions.microsoft.com> wrote in message news:0B63AB99-5824-4AFB-A206-D4CDF1BB9D48@microsoft.com... > Is it possible to chang...

Custom colors on network chart
Excel 2000 In a workbook,I have a combination chart - having three series as area series with a custom color. There are also line series plotting over the area series. The area series colors were set using Tools>Options>Color, Select the color (from the palette), Modify, Custom, then the color was created. Works fine in the workbook chart. However, this chart has now become part of a PowerPoint slide show on a network, where, the custom color of the workbook does not carry over to the network users. Is there a way to program the custom colors to carry over to the network s...

Changing default lists
If I type an asterisk (*) or a number + a period (1.) and then a space, Word starts an unordered/ordered list. I have defined some lists with formats that I prefer to the default lists that Word chooses. Is there a way that I can get Word to use my lists when I type "* " or "1. "? No, the automatic application of numbering isn't that "intelligent." What you can do is create your own lists linked to styles. For single-level numbering, the easiest approach is to modify the built-in List Bullet and List Number styles, respectively. -- Stefan B...

Axis Values Keep changing
I have a scientific table of values containing time increments as column entries (0, .5, 1.0, 1.5, 2.0, etc.). There is a corresponding record entry for each of these time increments. When I attempt to create a CHART, however, that range of values changes to 1, 2, 3, 4, etc.). I've played with changing the increment values to number format, and I can't seem to get beyond what excel's chart wizard insists upon doing to this range of values. Any suggestions? You have been making a LINE chart when you need an XY chart best wishes -- Bernard V Liengme Microsoft Excel MVP htt...

Change "zoom" size in publisher and set as a default?
I would like to change the default "zoom" setting in publisher. I have not found how to change this. Suggestions? SheilaC <SheilaC@discussions.microsoft.com> was very recently heard to utter: > I would like to change the default "zoom" setting in publisher. I > have not found how to change this. Suggestions? Default Zoom add-in is available at http://www.publishermvps.com/Programming/AddIns/tabid/43/Default.aspx -- Ed Bennett - MVP Microsoft Publisher What version Publisher? An Add-in here, scroll down... Default Zoom Add-in v1.0 (for Publisher 2...

How do I set the date to change into the right format?
I need to be able to type 15/06/06 or 150606 and for it to change to 15-jun-06 when I leave the cell. I have tried all kinds of things, and usually, it stays as I typed it, or it shows like I type it mm-dd-yy. Can someone please tell me how to format the date cell properly? I have so many cover sheets to type for the month end...!Thank you! Did you try to format your cells to the format you want, in your case Format/Cells/Date/[*chosse*]? Henk "Tab In The Office" wrote: > I need to be able to type 15/06/06 or 150606 and for it to change to > 15-jun-06 when I leave t...

change from copy & paste task pane (yuk) to c&p little box
Help I hate the task pane for copy and pasting it is too big and too far away from the copy and paste area I much prefered my office 2000 little copy andpaste box that came up automatically, the task pane doesn't even if the it's checked to.Is there a way I can get the little box display of copy and paste items instead of the task pane. ...

How to Change File Extension
Hi All, I am new to VC++.NET. I have a stuck with a problem. I am creating a temporary file in C:\Windows\Temp directory. The file name would be <filename>.tmp. Now if I want to change the extension to some other extension like ".doc" or ".xml" , how can I do it? Is it possible in VC++.NET. In one of the post, I saw we have to invoke IDR_MAINFRAME. But I am not finding any such thing in VC++.NET. Thanks, Yesh use CFile::Rename "yesh" <yeshwanth.hv@gmail.com> wrote in message news:1160729614.279921.50800@b28g2000cwb.googleg...

Matching cells by content then cell fill with color
Thanks to JEM, I am using this routine to color three consecutive cell a specific color, in this case red: Public Sub ThreeCellsRed() ActiveCell.Resize(1,3).Interior.ColorIndex = 3 End Sub What I need now is a way for the routine to continue to find all th similar cells, let's say for sake of disc they are people's names, s when I execute the above on my name, mrh, I want it to continue in th worksheet and find all exact matches and color those same cells red. Another thought, say my name (MRH) is in "A1" and it is also in "D1". But in "D1" I use "...