Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pie chart for win32 app

179 views
Skip to first unread message

michael

unread,
Dec 3, 2008, 10:37:29 PM12/3/08
to
I wanna draw some pie chart in a win32/sdk application
where could I get some sample code .

3d pie chart is better

thanks


Joseph M. Newcomer

unread,
Dec 3, 2008, 11:00:36 PM12/3/08
to
Good news: there's an example of how to do this in the code for our book "Win32
Programming"
Bad news: its a 13MB download
Sort-of-bad news: it is written in pseudo-C++ (I was trying to show how to write C code,
but I wasn't going to write the whole app in C, that takes far too much effort), so you'll
have to do do a bit of fairly trivial translation to get it into pure MFC code.

www.flounder.com/downloads.htm
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

jean

unread,
Dec 4, 2008, 12:32:41 AM12/4/08
to

"michael" <mick...@hotmail.com> wrote in message
news:OkImhGcV...@TK2MSFTNGP04.phx.gbl...

>I wanna draw some pie chart in a win32/sdk application
> where could I get some sample code .

It's automatic in Win32 with the native pie chart control
You can ask on Advanced Win32 api newsgroup
news://comp.os.ms-windows.programmer.win32
where it has often been discussed..


michael

unread,
Dec 4, 2008, 12:59:09 AM12/4/08
to
Thanks a lot I download the whole stuff and got dozens of sample code
,which one is the pie chart sample
and by the way the url is http://www.flounder.com/download.htm

"Joseph M. Newcomer" <newc...@flounder.com>
??????:6alej41epu0cjp2ra...@4ax.com...

Joseph M. Newcomer

unread,
Dec 4, 2008, 1:48:45 AM12/4/08
to
Find in files: Pie
joe

marc

unread,
Dec 4, 2008, 4:39:52 AM12/4/08
to
On 4 déc, 06:59, "michael" <mick2j...@hotmail.com> wrote:
>  I download the whole stuff and got dozens of sample code
> ,which one is the pie chart sample

It's bullshit (and visually horrible)
As it has been said, just use the pie chart control. It has been
created for that

Joseph M. Newcomer

unread,
Dec 4, 2008, 9:42:55 AM12/4/08
to
Here's the complete code from the file GDIExplorerView.cpp.

(a) what is bullshit about it? It shows some simple code for drawing a pie chart
(b) what is visually horrible about it?

I don't mind founded criticism, but you seem to have no basis for comment here. It is raw
Win32 API, but it was written for a raw Win32 API book.

Since you obviously know how to improve this code by making it non-bullshit, and by making
it conform to your version of beauty, please demonstrate the problems. Show better code.

Yes, it uses absolute integers, and that was the point of the exercise (it comes out
differently on different displays, but the goal was to relate actual coordinates to what
is going on).

This does not change the fact that if there is a pie-chart control, it is certainly a
better choice, but that does not change the fact that you have claimed my code is
incorrect and unaesthetic. Please demonstrate how to draw a pie chart, using raw Win32,
which comes out conforming to your notion of what such code should look like (I already
indicated that trivial translation was required to make this consistent with MFC).

Or please reference your book where you show how to do this correctly, or your Web site,
where you show how to do this correctly, and I will go read them. I'm always willing to
learn.

static void
bmpbrush_OnPaint(HWND hwnd, HDC hdc)
{
int xUL = -300;
int yUL = 200;
int xLR = 300;
int yLR = -200;
int xBegin = -250;
int yBegin = -100;
int xEnd = 0;
int yEnd = 250;
RECT rect;
RECT r;
#define BMP_CAPTION_OFFSET (-80)
HFONT font = createCaptionFont(-(abs(BMP_CAPTION_OFFSET)), TimesFont);
HBRUSH brush;
HBITMAP bmp;
int save = SaveDC(hdc);
SIZE size;

// Get the device context
// and establish the coordinate mapping

GetClientRect(hwnd, &rect);
SetMapMode(hdc, MM_ISOTROPIC);
SetViewportOrgEx(hdc, rect.right / 2, rect.bottom / 2, NULL);
SetWindowExtEx(hdc, 1000, 1000, NULL);
SetViewportExtEx(hdc, rect.right, - rect.bottom, NULL);

bmp = LoadBitmap(GetWindowInstance(hwnd), MAKEINTRESOURCE(IDB_MARBLE));
brush = CreatePatternBrush(bmp);

// Do a drop-shadow 3-D effect here
#define BMP_SHADOW (-20)
SelectBrush(hdc, GetStockObject(BLACK_BRUSH));
Ellipse(hdc, xUL, yUL+BMP_SHADOW, xLR, yLR+BMP_SHADOW);

SelectBrush(hdc, GetStockObject(WHITE_BRUSH));
Ellipse(hdc, xUL, yUL, xLR, yLR);


SelectBrush(hdc, brush);
Pie(hdc, xUL, yUL, xLR, yLR, xBegin, yBegin, xEnd, yEnd);

r = rect;
DPtoLP(hdc, (LPPOINT)&r, 2);
r.top = yLR + BMP_CAPTION_OFFSET;
r.bottom = yLR + 2 * BMP_CAPTION_OFFSET;
SelectFont(hdc, font);


ids_GetTextExtentPoint32(GetWindowInstance(hwnd), hdc, IDS_BMPBRUSH, &size);
r.bottom = r.top - size.cy;

ids_DrawText(GetWindowInstance(hwnd), hdc, IDS_BMPBRUSH, &r,
DT_CENTER);

RestoreDC(hdc, save);

DeleteFont(font);
DeleteBrush(brush);
DeleteBitmap(bmp);
}

AliR (VC++ MVP)

unread,
Dec 4, 2008, 12:05:39 PM12/4/08
to
I have used Nevron for years with great results. www.nevron.com

It looks great but the price is around $700. If you ask me it is worth the
professional look.
In the past they had a chart designer that you could use to visually create
your chart, and have it spit out the code for it, it worked great for every
language execpt c++, it caused alot of compiler errors that had to be fixed.
I don't know if they have that fixed yet or not, but even then it helped out
alot.

Here is their pie chart from their gallery:
http://www.nevron.com/Gallery.ChartForActiveX.PieChartsGallery.aspx

AliR.

"michael" <mick...@hotmail.com> wrote in message
news:OkImhGcV...@TK2MSFTNGP04.phx.gbl...

Patrick

unread,
Dec 6, 2008, 2:43:58 AM12/6/08
to

Right.
And for the 3D, you just have to set the 3DView property

AliR (VC++ MVP)

unread,
Dec 8, 2008, 10:54:29 AM12/8/08
to
I have seen a spike in BS criticism these days. The guy posted the comments
about your article, had only 129 posts total, 4 in mfc group. About 10 total
in other programming groups, and the rest were in tv.programming (72 posts)
and sport.football (55 post). (very similar profiles to the other posters
I'v seen).

I don't think the guy knows anything about computers other than maybe how to
get football stats, and watch some porn.

I guess they just want to get a raise out of people!

AliR.


BobF

unread,
Dec 8, 2008, 11:06:28 AM12/8/08
to

What is this about?

Tom Serface

unread,
Dec 8, 2008, 11:08:28 AM12/8/08
to
Let he who has never posted to the wrong forum by accident cast the first
stone :o)

Tom

"AliR (VC++ MVP)" <Al...@online.nospam> wrote in message
news:rrb%k.7014$W06....@flpi148.ffdc.sbc.com...

AliR (VC++ MVP)

unread,
Dec 8, 2008, 11:11:05 AM12/8/08
to
About marcs comment and Joe's response to his comment.

go to groups.google.com and search for marc....@caramail.com

He has been leaving useless comments about member posts all over programming
websites. (I guess its his hobby)

I was just telling Joe not to be upset about it (not that he would be).

AliR.


"BobF" <noth...@spamfree.world> wrote in message
news:OyzTk6UW...@TK2MSFTNGP03.phx.gbl...

AliR (VC++ MVP)

unread,
Dec 8, 2008, 11:12:45 AM12/8/08
to
That's not what I was saying.

I was refering to marcs comments such as:

>On 4 déc, 06:59, "michael" <mick2j...@hotmail.com> wrote:
>> I download the whole stuff and got dozens of sample code
>> ,which one is the pie chart sample

> It's bullshit (and visually horrible)
> As it has been said, just use the pie chart control. It has been
> created for that

AliR.


"Tom Serface" <tom.n...@camaswood.com> wrote in message
news:D3A8652B-41E8-480B...@microsoft.com...

Ajay Kalra

unread,
Dec 8, 2008, 11:48:06 AM12/8/08
to


That explains the ratings that Joe has been getting over last few
days. Someone is exlcusively tagging Joe's messages.

--
Ajay

James Juno

unread,
Dec 8, 2008, 11:51:50 AM12/8/08
to
Good research, AliR. Appears this marc character is lacking credibility.

I'm cursed at the moment with a contract that requires me to "interact" with
a bored DBA also stricken with a prima donna complex. I was angry at first,
now I just feel pity.

-JJ

"AliR (VC++ MVP)" <Al...@online.nospam> wrote in message

news:zIb%k.7017$W06....@flpi148.ffdc.sbc.com...

James Juno

unread,
Dec 8, 2008, 12:00:20 PM12/8/08
to
I hate to see that. I've been an MFC user for many years and people like
you, AliR and Joe are the only reason I read this group. If only all such
newsgroups had this kind of return for the cost.

Keep up the good work, guys, and remember many of us very much appreciate
your feedback even if we don't say it enough.

-JJ

"Ajay Kalra" <ajay...@yahoo.com> wrote in message
news:72f607cd-846b-4381...@d32g2000yqe.googlegroups.com...

BobF

unread,
Dec 8, 2008, 12:09:10 PM12/8/08
to
Ajay Kalra wrote:
>
> That explains the ratings that Joe has been getting over last few
> days. Someone is exlcusively tagging Joe's messages.
>

Where? Is there a link between this ng and a forum? I hope so - I've
looked and can't seem to find a connection ...

Ajay Kalra

unread,
Dec 8, 2008, 12:30:45 PM12/8/08
to

I go thru Google groups. I can see the ratings there. Try that out.

--
Ajay

Tom Serface

unread,
Dec 8, 2008, 1:00:46 PM12/8/08
to
Ah, that makes more sense.... :o) Disregard my ill attempt at humor.

Tom

"AliR (VC++ MVP)" <Al...@online.nospam> wrote in message

news:%Gb%k.7016$W06....@flpi148.ffdc.sbc.com...

BobF

unread,
Dec 8, 2008, 1:19:01 PM12/8/08
to
Ajay Kalra wrote:
> On Dec 8, 12:09 pm, BobF <notha...@spamfree.world> wrote:
>> Ajay Kalra wrote:
>>
>>> That explains the ratings that Joe has been getting over last few
>>> days. Someone is exlcusively tagging Joe's messages.
>> Where? Is there a link between this ng and a forum? I hope so - I've
>> looked and can't seem to find a connection ...
>
> I go thru Google groups.

Yuuuch! :-)

I can see the ratings there. Try that out.

Yep, I see ratings in profiles, but I don't see them on a post-by-post
level. No worry, I was just curious.

Ajay Kalra

unread,
Dec 8, 2008, 1:37:50 PM12/8/08
to

Only the posts that have ratings will show it. It could be that you
have to login to see them I dont know for sure. For some reason I
couldnt rate a post. It must be me.

--
Ajay


AliR (VC++ MVP)

unread,
Dec 8, 2008, 2:46:05 PM12/8/08
to
Once you login with a google account you can rate a post. It's on the
bottom of every post.

AliR.


"Ajay Kalra" <ajay...@yahoo.com> wrote in message

news:da27ed67-dcd1-4929...@a12g2000yqm.googlegroups.com...

Ajay Kalra

unread,
Dec 8, 2008, 2:52:28 PM12/8/08
to
On Dec 8, 2:46 pm, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
> Once you login with a google account you can rate a post.  It's on the
> bottom of every post.

Duh.. I was doing it at the top, which is the net result.

Thanks.
--
Ajay

Aras mm

unread,
Apr 10, 2011, 6:27:57 AM4/10/11
to
In system programming
Develop program allowing creates the pie charts with the following possibilities:
-Task of parameters of diagram including table of parameters of diagram color of each area of diagram, size of diagram;
Realize the possibility of conservation and reading the parameters of diagram in file
-the image of diagram on screen;
-the export of diagram in file of format *.bmp


>> On Wednesday, December 03, 2008 11:00 PM Joseph M. Newcomer wrote:

>> Good news: there's an example of how to do this in the code for our book "Win32
>> Programming"
>> Bad news: its a 13MB download
>> Sort-of-bad news: it is written in pseudo-C++ (I was trying to show how to write C code,
>> but I wasn't going to write the whole app in C, that takes far too much effort), so you'll
>> have to do do a bit of fairly trivial translation to get it into pure MFC code.
>>
>> www.flounder.com/downloads.htm
>> joe
>>
>> On Thu, 4 Dec 2008 11:37:29 +0800, "michael" <mick...@hotmail.com> wrote:
>>

>> Joseph M. Newcomer [MVP]
>> email: newc...@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm


>>> On Thursday, December 04, 2008 12:32 AM jean wrote:

>>> it is automatic in Win32 with the native pie chart control


>>> You can ask on Advanced Win32 api newsgroup

>>> where it has often been discussed..


>>>> On Thursday, December 04, 2008 12:59 AM michael wrote:

>>>> Thanks a lot I download the whole stuff and got dozens of sample code

>>>> ,which one is the pie chart sample

>>>> and by the way the url is http://www.flounder.com/download.htm
>>>>
>>>> "Joseph M. Newcomer" <newc...@flounder.com>
>>>> ??????:6alej41epu0cjp2ra...@4ax.com...


>>>>> On Thursday, December 04, 2008 1:48 AM Joseph M. Newcomer wrote:

>>>>> Find in files: Pie
>>>>> joe
>>>>>
>>>>>

>>>>> Joseph M. Newcomer [MVP]
>>>>> email: newc...@flounder.com
>>>>> Web: http://www.flounder.com
>>>>> MVP Tips: http://www.flounder.com/mvp_tips.htm


>>>>>> On Thursday, December 04, 2008 12:05 PM AliR \(VC++ MVP\) wrote:

>>>>>> I have used Nevron for years with great results. www.nevron.com
>>>>>>
>>>>>> It looks great but the price is around $700. If you ask me it is worth the
>>>>>> professional look.
>>>>>> In the past they had a chart designer that you could use to visually create
>>>>>> your chart, and have it spit out the code for it, it worked great for every
>>>>>> language execpt c++, it caused alot of compiler errors that had to be fixed.
>>>>>> I don't know if they have that fixed yet or not, but even then it helped out
>>>>>> alot.
>>>>>>
>>>>>> Here is their pie chart from their gallery:
>>>>>> http://www.nevron.com/Gallery.ChartForActiveX.PieChartsGallery.aspx
>>>>>>
>>>>>> AliR.
>>>>>>
>>>>>> "michael" <mick...@hotmail.com> wrote in message
>>>>>> news:OkImhGcV...@TK2MSFTNGP04.phx.gbl...


>>>>>>> On Monday, December 08, 2008 11:06 AM BobF wrote:

>>>>>>> What is this about?
>>>>>>>
>>>>>>> AliR (VC++ MVP) wrote:


>>>>>>>> On Monday, December 08, 2008 11:08 AM Tom Serface wrote:

>>>>>>>> Let he who has never posted to the wrong forum by accident cast the first
>>>>>>>> stone :o)
>>>>>>>>
>>>>>>>> Tom


>>>>>>>>> On Monday, December 08, 2008 11:11 AM AliR \(VC++ MVP\) wrote:

>>>>>>>>> About marcs comment and Joe's response to his comment.
>>>>>>>>>
>>>>>>>>> go to groups.google.com and search for marc....@caramail.com
>>>>>>>>>
>>>>>>>>> He has been leaving useless comments about member posts all over programming
>>>>>>>>> websites. (I guess its his hobby)
>>>>>>>>>
>>>>>>>>> I was just telling Joe not to be upset about it (not that he would be).
>>>>>>>>>
>>>>>>>>> AliR.
>>>>>>>>>
>>>>>>>>>

>>>>>>>>> "BobF" <noth...@spamfree.world> wrote in message
>>>>>>>>> news:OyzTk6UW...@TK2MSFTNGP03.phx.gbl...


>>>>>>>>>> On Monday, December 08, 2008 12:00 PM James Juno wrote:

>>>>>>>>>> I hate to see that. I've been an MFC user for many years and people like
>>>>>>>>>> you, AliR and Joe are the only reason I read this group. If only all such
>>>>>>>>>> newsgroups had this kind of return for the cost.
>>>>>>>>>>
>>>>>>>>>> Keep up the good work, guys, and remember many of us very much appreciate
>>>>>>>>>> your feedback even if we don't say it enough.
>>>>>>>>>>
>>>>>>>>>> -JJ
>>>>>>>>>>

>>>>>>>>>> "Ajay Kalra" <ajay...@yahoo.com> wrote in message

>>>>>>>>>> news:72f607cd-846b-4381...@d32g2000yqe.googlegroups.com...


>>>>>>>>>> On Dec 8, 10:54 am, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> That explains the ratings that Joe has been getting over last few
>>>>>>>>>> days. Someone is exlcusively tagging Joe's messages.
>>>>>>>>>>

>>>>>>>>>> --
>>>>>>>>>> Ajay


>>>>>>>>>>> On Monday, December 08, 2008 12:09 PM BobF wrote:

>>>>>>>>>>> Ajay Kalra wrote:
>>>>>>>>>>>
>>>>>>>>>>> Where? Is there a link between this ng and a forum? I hope so - I have
>>>>>>>>>>> looked and cannot seem to find a connection ...


>>>>>>>>>>>> On Monday, December 08, 2008 1:00 PM Tom Serface wrote:

>>>>>>>>>>>> Ah, that makes more sense.... :o) Disregard my ill attempt at humor.
>>>>>>>>>>>>
>>>>>>>>>>>> Tom


>>>>>>>>>>>>> On Monday, December 08, 2008 1:19 PM BobF wrote:

>>>>>>>>>>>>> Ajay Kalra wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Yuuuch! :-)
>>>>>>>>>>>>>
>>>>>>>>>>>>> I can see the ratings there. Try that out.
>>>>>>>>>>>>>

>>>>>>>>>>>>> Yep, I see ratings in profiles, but I do not see them on a post-by-post


>>>>>>>>>>>>> level. No worry, I was just curious.


>>>>>>>>>>>>>> On Monday, December 08, 2008 2:46 PM AliR \(VC++ MVP\) wrote:

>>>>>>>>>>>>>> Once you login with a google account you can rate a post. It's on the
>>>>>>>>>>>>>> bottom of every post.
>>>>>>>>>>>>>>


>>>>>>>>>>>>>>> On Monday, December 08, 2008 9:57 PM Ajay Kalra wrote:

>>>>>>>>>>>>>>> ments
>>>>>>>>>>>>>>> tal
>>>>>>>>>>>>>>> s)
>>>>>>>>>>>>>>> to


>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> That explains the ratings that Joe has been getting over last few
>>>>>>>>>>>>>>> days. Someone is exlcusively tagging Joe's messages.
>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> Ajay


>>>>>>>>>>>>>>>> On Monday, December 08, 2008 9:57 PM Ajay Kalra wrote:

>>>>>>>>>>>>>>>> e
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I go thru Google groups. I can see the ratings there. Try that out.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> Ajay


>>>>>>>>>>>>>>>>> On Monday, December 08, 2008 9:57 PM Ajay Kalra wrote:

>>>>>>>>>>>>>>>>> I have


>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Only the posts that have ratings will show it. It could be that you
>>>>>>>>>>>>>>>>> have to login to see them I dont know for sure. For some reason I
>>>>>>>>>>>>>>>>> couldnt rate a post. It must be me.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>> Ajay

Joseph M. Newcomer

unread,
Apr 10, 2011, 2:12:56 PM4/10/11
to
See my citation below. The only tricky thing is the pie algorithm; everything else you
are asking for is trivial programming.
joe

Joseph M. Newcomer

unread,
Apr 10, 2011, 3:35:03 PM4/10/11
to
To be more specific, see below...

On Sun, 10 Apr 2011 14:12:56 -0400, Joseph M. Newcomer <newc...@flounder.com> wrote:

>See my citation below. The only tricky thing is the pie algorithm; everything else you
>are asking for is trivial programming.
> joe
>On Sun, 10 Apr 2011 10:27:57 GMT, Aras mm <energe...@rocketmail.com> wrote:
>
>>In system programming
>>Develop program allowing creates the pie charts with the following possibilities:
>>-Task of parameters of diagram including table of parameters of diagram color of each area of diagram, size of diagram;

****
This is Freshman Programming 101.
****


>>Realize the possibility of conservation and reading the parameters of diagram in file

****
THis is an assignment for the third week of Freshman Programming 101
****


>>-the image of diagram on screen;

****
This was the only vaguely tricky part, and I pointed out at the download
****


>>-the export of diagram in file of format *.bmp

*****
This is essentially trivial. For example, see my essay on screen capture on my MVP Tips
site. Or just write the bitmap to a DC. Converting the DC to a file is Second Semester
Freshman Programming, and there are tons of articles on the Web on how to do it. Check
out my GradientFill Explorer as well, which already does this. Note that I learned how to
do this with a simple google search for some code.
*****

0 new messages