<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CPoint an Funktion übergeben]]></title><description><![CDATA[<p>Ich steh mal wieder im Walde.<br />
Ich möchte mir eine Funktion schreiben, mit der ich einen Graphen in einem bestimmten Bereich plotten kann.<br />
Leider weiß ich nicht, wie ich CPoint richtig an die Funktion übergeben soll.</p>
<pre><code class="language-cpp">void CChildView::DrawGraph(CRect r,CPoint* p,int pSize)
{
	CDC* pDC;
	GetClientRect(rClient);
	pDC = (CDC*) GetDC();
	CPoint* point = new CPoint[40];
	int i,j;

	double ymax = 0;
	double ymin = 0;
	double hSize = r.right - r.left;
	double vSize = r.top - r.bottom;

	long* py = &amp;p-&gt;y;
	long* px = &amp;p-&gt;x;

	// find abs. Maximum in p
	for(i=0;i&lt;pSize;i++)
	{
		if(p-&gt;y &gt;&gt; sizeof(point[0].y)*i &gt; ymax) ymax = p-&gt;y &gt;&gt; sizeof(point[0].y)*i;
		if(p-&gt;y &gt;&gt; sizeof(point[0].y)*i &lt; ymin) ymin = p-&gt;y &gt;&gt; sizeof(point[0].y)*i ;
	}

	j=0;
	for(i=0;i&lt;pSize;i++)
	{
		point[j].x=r.left + i * (r.right-r.left) / pSize;
		point[j].y=r.bottom - (r.bottom-r.top)/2 - (p-&gt;y &gt;&gt; sizeof(point[0].y)*i) * (r.bottom-r.top) / 2;
		j++;
	}

	pDC-&gt;Polyline(point,pSize);

	ReleaseDC(pDC);
	delete point;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/184113/cpoint-an-funktion-übergeben</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 00:10:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/184113.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 Jun 2007 13:02:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CPoint an Funktion übergeben on Tue, 12 Jun 2007 13:02:15 GMT]]></title><description><![CDATA[<p>Ich steh mal wieder im Walde.<br />
Ich möchte mir eine Funktion schreiben, mit der ich einen Graphen in einem bestimmten Bereich plotten kann.<br />
Leider weiß ich nicht, wie ich CPoint richtig an die Funktion übergeben soll.</p>
<pre><code class="language-cpp">void CChildView::DrawGraph(CRect r,CPoint* p,int pSize)
{
	CDC* pDC;
	GetClientRect(rClient);
	pDC = (CDC*) GetDC();
	CPoint* point = new CPoint[40];
	int i,j;

	double ymax = 0;
	double ymin = 0;
	double hSize = r.right - r.left;
	double vSize = r.top - r.bottom;

	long* py = &amp;p-&gt;y;
	long* px = &amp;p-&gt;x;

	// find abs. Maximum in p
	for(i=0;i&lt;pSize;i++)
	{
		if(p-&gt;y &gt;&gt; sizeof(point[0].y)*i &gt; ymax) ymax = p-&gt;y &gt;&gt; sizeof(point[0].y)*i;
		if(p-&gt;y &gt;&gt; sizeof(point[0].y)*i &lt; ymin) ymin = p-&gt;y &gt;&gt; sizeof(point[0].y)*i ;
	}

	j=0;
	for(i=0;i&lt;pSize;i++)
	{
		point[j].x=r.left + i * (r.right-r.left) / pSize;
		point[j].y=r.bottom - (r.bottom-r.top)/2 - (p-&gt;y &gt;&gt; sizeof(point[0].y)*i) * (r.bottom-r.top) / 2;
		j++;
	}

	pDC-&gt;Polyline(point,pSize);

	ReleaseDC(pDC);
	delete point;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1303985</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1303985</guid><dc:creator><![CDATA[etsmart]]></dc:creator><pubDate>Tue, 12 Jun 2007 13:02:15 GMT</pubDate></item><item><title><![CDATA[Reply to CPoint an Funktion übergeben on Tue, 12 Jun 2007 13:20:45 GMT]]></title><description><![CDATA[<p>Und was ist nun Dein Problem? Ich verstehe es nicht?</p>
<p>BTW: Warum allokierst Du point nicht extakt nach pSize?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1304017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1304017</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 12 Jun 2007 13:20:45 GMT</pubDate></item><item><title><![CDATA[Reply to CPoint an Funktion übergeben on Wed, 13 Jun 2007 08:31:01 GMT]]></title><description><![CDATA[<p>etsmart schrieb:</p>
<blockquote>
<p>Ich steh mal wieder im Walde.<br />
Ich möchte mir eine Funktion schreiben, mit der ich einen Graphen in einem bestimmten Bereich plotten kann.<br />
Leider weiß ich nicht, wie ich CPoint richtig an die Funktion übergeben soll.</p>
</blockquote>
<p>Was verstehst Du unter &quot;richtig übergeben&quot;? Wenn der Parameter immer erforderlich ist und in der aufrufenden Funktion nicht verändert werden soll/darf, würde ich CPoint const &amp; nehmen.</p>
<blockquote>
<pre><code class="language-cpp">CPoint* point = new CPoint[40];

....

	delete point;
}
</code></pre>
</blockquote>
<p>delete <strong>[]</strong> point;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1304629</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1304629</guid><dc:creator><![CDATA[jencas]]></dc:creator><pubDate>Wed, 13 Jun 2007 08:31:01 GMT</pubDate></item><item><title><![CDATA[Reply to CPoint an Funktion übergeben on Wed, 13 Jun 2007 10:36:07 GMT]]></title><description><![CDATA[<p>CPoint unterstützt die Umwandlung nach POINT, die folgende Variante wird in der MFC meist benutzt:</p>
<pre><code class="language-cpp">//Deklaration:
void CChildView::DrawGraph(CRect r,const POINT&amp; pt,int pSize)
//Aufruf:
CPoint pt(x,y);
DrawGraph(r,pt,pSize);
</code></pre>
<p>Das gleiche gilt auch für CRect, siehe auch GetClientRect.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1304712</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1304712</guid><dc:creator><![CDATA[connan]]></dc:creator><pubDate>Wed, 13 Jun 2007 10:36:07 GMT</pubDate></item><item><title><![CDATA[Reply to CPoint an Funktion übergeben on Wed, 13 Jun 2007 12:58:03 GMT]]></title><description><![CDATA[<p>Klappt jetzt. Danke!</p>
<pre><code class="language-cpp">void CChildView::DrawGraph(CRect r,CPoint* p,int pSize)
{
	CDC* pDC;
	GetClientRect(rClient);
	pDC = (CDC*) GetDC();
	CPoint* point = new CPoint[pSize];
	int i,j;		
	double ymax = 0;
	double ymin = 0;
	double hSize = r.right - r.left;
	double vSize = r.top - r.bottom;

	for(i=0;i&lt;pSize;i++)
	{
		if(p[i].y &gt; ymax) ymax = p[i].y;
		if(p[i].y &lt; ymin) ymin = p[i].y;
	}

	j=0;
	for(i=0;i&lt;pSize;i++)
	{
		point[j].x=r.left + i * (r.right-r.left) / pSize * 1.025;
		point[j].y=r.bottom - (r.bottom-r.top)/2 - (p[j].y) * (r.bottom-r.top) / (2 * sqrt(pow(ymax,2)+pow(ymin,2)));
		j++;
	}

	char* buffer1 = new char[sizeof(ymax)/sizeof(double)+1];		// must be increased by 1
	_itoa((ymax/1e6),buffer1,10);
	pDC-&gt;Polyline(point,pSize);
	pDC-&gt;DrawText(buffer1,r,DT_LEFT);

	char* buffer2 = new char[sizeof(ymin)/sizeof(double)+1];		// must be increased by 1
	r.top = r.bottom*0.96;
	_itoa((ymin/1e6),buffer2,10);
	pDC-&gt;Polyline(point,pSize);
	pDC-&gt;DrawText(buffer2,r,DT_LEFT);

	delete (point);
	delete (buffer1);
	delete (buffer2);
	ReleaseDC(pDC);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1304822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1304822</guid><dc:creator><![CDATA[etsmart]]></dc:creator><pubDate>Wed, 13 Jun 2007 12:58:03 GMT</pubDate></item></channel></rss>