<?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[Woher bekomme ich CWnd eines Fensters]]></title><description><![CDATA[<p>Ich möchte eine Funktion WriteWindowToDIB( LPTSTR szFile, CWnd *pWnd )<br />
benutzen die als Eingabe ein CWnd erwartet.<br />
Mir ist jedoch unklar woher ich diesen Wert bekomme.<br />
Konkret habe ich ein Überladenes CStatic Fenster dessen Inhalt ich mit dieser Funktion abspeichern möchte.</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/179515/woher-bekomme-ich-cwnd-eines-fensters</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 13:43:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/179515.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Apr 2007 18:20:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Sun, 22 Apr 2007 18:20:14 GMT]]></title><description><![CDATA[<p>Ich möchte eine Funktion WriteWindowToDIB( LPTSTR szFile, CWnd *pWnd )<br />
benutzen die als Eingabe ein CWnd erwartet.<br />
Mir ist jedoch unklar woher ich diesen Wert bekomme.<br />
Konkret habe ich ein Überladenes CStatic Fenster dessen Inhalt ich mit dieser Funktion abspeichern möchte.</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271342</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Sun, 22 Apr 2007 18:20:14 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Sun, 22 Apr 2007 20:36:09 GMT]]></title><description><![CDATA[<p>Du suchst vermutlich FindWindow.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271391</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271391</guid><dc:creator><![CDATA[Dito]]></dc:creator><pubDate>Sun, 22 Apr 2007 20:36:09 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Sun, 22 Apr 2007 21:13:57 GMT]]></title><description><![CDATA[<p>Dito schrieb:</p>
<blockquote>
<p>Du suchst vermutlich FindWindow.</p>
</blockquote>
<p>Ich habe mal danach in MSDN gesucht, aber das Beispiel bringt mich nicht soweit, dass ich daraus erkennen könnte wie ich von einem CStatic Window in einem Dialog das CWnd ermittle.</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271410</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271410</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Sun, 22 Apr 2007 21:13:57 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Mon, 23 Apr 2007 05:11:17 GMT]]></title><description><![CDATA[<p>Dann schau mal unter GetDlgItem in der MSDN nach. Damit sollte es doch<br />
auch gehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271452</guid><dc:creator><![CDATA[Dito]]></dc:creator><pubDate>Mon, 23 Apr 2007 05:11:17 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Mon, 23 Apr 2007 14:18:20 GMT]]></title><description><![CDATA[<p>Ich weiss nicht, wo Dein Problem liegt. CStatic ist doch von CWnd abgeleitet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271794</guid><dc:creator><![CDATA[jencas]]></dc:creator><pubDate>Mon, 23 Apr 2007 14:18:20 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Mon, 23 Apr 2007 14:30:32 GMT]]></title><description><![CDATA[<p>jencas schrieb:</p>
<blockquote>
<p>Ich weiss nicht, wo Dein Problem liegt. CStatic ist doch von CWnd abgeleitet.</p>
</blockquote>
<p>Ich habe folgende Funktion</p>
<pre><code class="language-cpp">BOOL CBitmapPicture::WriteWindowToDIB( LPTSTR szFile, CWnd *pWnd )
{
	CBitmap 	bitmap;
	CWindowDC	dc(pWnd);
	CDC 		memDC;
	CRect		rect;

	memDC.CreateCompatibleDC(&amp;dc);

	pWnd-&gt;GetWindowRect(rect);

	bitmap.CreateCompatibleBitmap(&amp;dc, rect.Width(),rect.Height() );

	CBitmap* pOldBitmap = memDC.SelectObject(&amp;bitmap);
	memDC.BitBlt(0, 0, rect.Width(),rect.Height(), &amp;dc, 0, 0, SRCCOPY);

	memDC.SelectObject(pOldBitmap);

	// Convert the bitmap to a DIB
	HANDLE hDIB = DDBToDIB( bitmap, BI_RGB, &amp;pal );

	if( hDIB == NULL )
		return FALSE;

	// Write it to file
	WriteDIBToFile( szFile, hDIB );

	// Free the memory allocated by DDBToDIB for the DIB
	GlobalFree( hDIB );
	return TRUE;
}
</code></pre>
<p>die als Eingabe ein CWnd *pWnd für das zu speichernde Fenster erwartet und mir ist unklar wie ich für den Inhalt meiner Cstatic Klasse an diesen Wert herankomme.</p>
<p>Unabhängig davon ist mir der Unterschied zuwischen</p>
<pre><code class="language-cpp">CWindowDC	dc(pWnd);
</code></pre>
<p>und</p>
<pre><code class="language-cpp">CDC dc;
</code></pre>
<p>nicht klar.</p>
<p>Wie ich mit GetDlgItem oder FindWindow daran komme ist mir auch unklar, da mir ein entsprechendes Beispiel fehlt.</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271801</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271801</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Mon, 23 Apr 2007 14:30:32 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Tue, 24 Apr 2007 08:54:23 GMT]]></title><description><![CDATA[<p>Verpasse Deinem CStatic im Resourceeditor eine eindeutige Resource-ID, z.B. IDC_STATIC_FOOBAR. Mit GetDlgItem(IDC_STATIC_FOOBAR) bekommst Du im Dialog den gewünschten Pointer auf ein CWnd.<br />
Und nur mal so am Rande: Du solltest Dir aber zumindestens Grundkenntnisse in C++ und den MFC aneignen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1272235</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272235</guid><dc:creator><![CDATA[jencas]]></dc:creator><pubDate>Tue, 24 Apr 2007 08:54:23 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Tue, 24 Apr 2007 12:25:52 GMT]]></title><description><![CDATA[<p>jencas schrieb:</p>
<blockquote>
<p>Verpasse Deinem CStatic im Resourceeditor eine eindeutige Resource-ID, z.B. IDC_STATIC_FOOBAR. Mit GetDlgItem(IDC_STATIC_FOOBAR) bekommst Du im Dialog den gewünschten Pointer auf ein CWnd.</p>
</blockquote>
<p>Ich habe es probiert mit</p>
<pre><code class="language-cpp">BOOL CGraphCtrl::SaveBitmap(CString csFileName)
{
	CWnd pWnd = GetDlgItem(IDC_PLOT);
	BOOL Result = BitmapOperations.WriteWindowToDIB((LPCTSTR)csFileName, &amp;pWnd);
</code></pre>
<p>was mir nur ein</p>
<blockquote>
<p>error C2065: 'IDC_PLOT': nichtdeklarierter Bezeichner</p>
</blockquote>
<p>liefert. Das Window hat aber definitiv diese ID.</p>
<p>Was mich daran noch irritiert ist die Tatsache das ich ja eine Instanz dieses Window habe, und erartet hätte darüber an den CWnd Wert heranzukommen.</p>
<p>jencas schrieb:</p>
<blockquote>
<p>Und nur mal so am Rande: Du solltest Dir aber zumindestens Grundkenntnisse in C++ und den MFC aneignen.</p>
</blockquote>
<p>Ich denke meine Grundkenntnisse in C++ sind zum verstehen meiner Fragen und eurer Antworten ausreichend. Was MFC angeht - es ist schwer zu lernen. Ich besitze 3 Bücher - ein neues das mir fast nichts gebracht hat, ein MFC in 21 Tagen was aber VS6 behandelt und deshalb der Code haufig nicht kompiliert und das Buch 'Microsoft Press - Programming Windows with MFC, 2nd Edition' was aber auch nicht detailiert genug ist. Die MSDN ist häufig so geschrieben das ich den Zusammenhang mit meinen Problemen nicht erkennen kann.<br />
Daher bleiben viele Fragen offen, die ich versuche unter anderem hier gelöst zu bekommen. Sollte ich mich dabei allzu dumm anstellen tut mir das leid.<br />
Was mir definitiv fehlt ist der Erfahrungshorizont von mehreren Jahren Arbeit mit der MFC API, so dass mir Zusammenhänge einfach nicht offensichtlich klar sind.</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1272390</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272390</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Tue, 24 Apr 2007 12:25:52 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Tue, 24 Apr 2007 12:53:54 GMT]]></title><description><![CDATA[<p>Unter der Annahme, dass du ein Static-Control hast, das manuell(!!!)<br />
umgetextet wurde von IDC_STATIC auf IDC_STATIC<strong>B</strong>:</p>
<pre><code class="language-cpp">CWnd *pWnd = GetDlgItem(IDC_STATICB);
pWnd-&gt;SendMessage(WM_SETTEXT, 0, (LPARAM) &quot;www.google.de&quot;);
</code></pre>
<p>Ok ok, nur als einfaches Beispiel...man hätte auch gleich sagen können</p>
<pre><code class="language-cpp">GetDlgItem(IDC_STATICB)-&gt;SetWindowText(&quot;www.google.de&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1272420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272420</guid><dc:creator><![CDATA[Dito]]></dc:creator><pubDate>Tue, 24 Apr 2007 12:53:54 GMT</pubDate></item><item><title><![CDATA[Reply to Woher bekomme ich CWnd eines Fensters on Wed, 25 Apr 2007 11:55:40 GMT]]></title><description><![CDATA[<p>pospiech schrieb:</p>
<blockquote>
<p>Ich habe es probiert mit</p>
<pre><code class="language-cpp">BOOL CGraphCtrl::SaveBitmap(CString csFileName)
{
	CWnd pWnd = GetDlgItem(IDC_PLOT);
	BOOL Result = BitmapOperations.WriteWindowToDIB((LPCTSTR)csFileName, &amp;pWnd);
</code></pre>
<p>was mir nur ein</p>
<blockquote>
<p>error C2065: 'IDC_PLOT': nichtdeklarierter Bezeichner</p>
</blockquote>
<p>liefert. Das Window hat aber definitiv diese ID.</p>
</blockquote>
<p>Ist das von CStatic abgeleitete Control zufälligerweise das CGraphCtrl? Wenn ja, dann:</p>
<pre><code class="language-cpp">BOOL CGraphCtrl::SaveBitmap(CString csFileName)
{
	BOOL Result = BitmapOperations.WriteWindowToDIB((LPCTSTR)csFileName, this);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1273129</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1273129</guid><dc:creator><![CDATA[jencas]]></dc:creator><pubDate>Wed, 25 Apr 2007 11:55:40 GMT</pubDate></item></channel></rss>