MFC中对话框上的线图 [英] Line Graph on Dialog Box in MFC
问题描述
Hello Everyone .. !!
任何人都可以告诉我如何在MFC中的对话框上绘制线图。
我有一个带有一些值的数组,我需要使用这些值生成一个图形。我应该使用哪种MFC工具/类?我以前从未在图表上工作,所以请人们帮帮我....
Hello Everyone..!!
Can anyone please tell me how to draw a line graph on a dialog box in MFC.
I have an array with some values and I need to generate a graph using those values. Which MFC Tool / Class should I use? I have never worked on graphs before so please people help me out....
推荐答案
我不确定是否有一个简单的MFC类来执行此操作。您可以使用静态控制 [ SS_OWNERDRAW $ c $的对话框中的microsoft.com/en-us/library/bb760773.aspx\"target =_ blanktitle =新窗口> ^ ] c>财产。然后,您可以在 WM_DRAWITEM
消息 [ ^ ] 。
I am not sure if there is a simple MFC class to do this. You can do it with a Static Control[^] in your dialog that has theSS_OWNERDRAW
property. You can then add your lines in the handler for theWM_DRAWITEM
message[^].
您可以使用图形基元( GDI $ c $)绘制自己(在 OnPaint
处理程序中) c>或 GDI +
)或者您可以使用图表控件,例如,Cedric的高速制图控制 [ ^ ]。
[更新]
假设你有一个坐标数组,想要创建一个线性图。
首先你必须找到 xmin,xmax,ymin,ymax
为了缩放(和平移)所有坐标以适应屏幕矩形你打算使用:
You may draw yourself (inOnPaint
handler) using graphic primitives (GDI
orGDI+
) or you may use a chart control, like, for instance, Cedric''s High-speed Charting Control[^].
[Update]
Suppose you have an array of coordinates and want to create a linear graph.
First you have to findxmin, xmax, ymin, ymax
in order to scale (and translate) all the coordinates to fit into the screen rectangle you intend to use:
x[i] = rcx + rcwidth/(xmax-xmin)* x[i];
y[i] = rcy - rcheight/(ymax-ymin)* y[i];
其中 rcx,rcy
是屏幕矩形左上角的坐标, rcwidth,rcheight
是它的尺寸。
最后你有绘制连接连续点的所有线,例如
where rcx, rcy
are the coordinates of the top-left point of the screen rectangle and rcwidth,rcheight
are its dimensions.
Finally you have to draw all the lines connecting successive points, e.g.
MoveToEx(hdc, x[0], y[0]);
for(n=1; n<N; ++n)
LineTo(hdc, x[n], y[n]);
[/ Update]
这篇关于MFC中对话框上的线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!