3

I want to plot a graph out of simple functions/set of coordinates in a window. I know the c++ win32 basics and I can make a simple window with buttons and other control objects. But which is the fastest and easiest library to plot a graph to my program?

2 Answers 2

2

I expect you are using Win32 API (not CLR).

Theory is easy, you need to obain device context withing WM_PAINT message. You can use main window or any child window (control - static, button) inside main window.

Here are some usefull links: http://www.codeproject.com/Articles/2078/Guide-to-WIN32-Paint-for-Intermediates

http://www.codeproject.com/Articles/66250/BeginPaint-EndPaint-or-GetDC-ReleaseDC.aspx

eg:

case WM_PAINT:
    BeginPaint(hWnd, &ps);
    LineTo(ps.hDC, 30,30);
    EndPaint(hWnd, &ps);
return 0;

This will draw line from 0,0 to 30,30

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the quick and helpful answer! I made it work. Now I just have to find a way to make a rectangle where the line is drawn.
Hi @Janman, no problem, take a look here : msdn.microsoft.com/en-us/library/dd162898%28v=vs.85%29.aspx use it as follows inside BeginPaint and EndPaint : Rectangle(ps.hDC, 0, 0, 30, 30)
2

Here is the light, easy to use library: http://www.codeproject.com/Articles/1546/Plot-Graphic-Library

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.