<?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[Bitmap-Problem]]></title><description><![CDATA[<p>Hi,</p>
<p>hab ein kleines Problem beim darstellen eines Bitmaps auf einem Button. Also das Bitmap wird aus einer Liste geladen und soll dann angezeigt werden. Bei einer PictureBox geht das ohne Problem nur auf dem Button krieg ich den nicht geladen mit SetBitmap. Hier mal der Code:</p>
<pre><code class="language-cpp">void  Bilder::DrawSelectedImage()
{

	int size = 128;
	CString	strPath;
	CBitmap bitmap,bit;
	BITMAP bm;

	// read the image file
	strPath = m_strImageDir + &quot;\\&quot; + m_VectorImageNames[m_nSelectedItem];
	bitmap.Attach(LoadImage(NULL,strPath,IMAGE_BITMAP,NULL,NULL,LR_LOADFROMFILE|LR_DEFAULTCOLOR|LR_DEFAULTSIZE));

	bitmap.GetObject(sizeof(bm), &amp;bm); 
	{ 
		CDC speicherDC; 
		speicherDC.CreateCompatibleDC(GetDC()); 
		speicherDC.SelectObject(&amp;bitmap); 

		CDC BmpDC; 
		BmpDC.CreateCompatibleDC(GetDC()); 
		bit.CreateCompatibleBitmap(GetDC(),size,size);
		BmpDC.SelectObject(&amp;bit); 

		BmpDC.SetStretchBltMode(HALFTONE);
			::SetBrushOrgEx(BmpDC.m_hDC,0,0,NULL);

		BmpDC.StretchBlt(0, 0,size,size,&amp;speicherDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); 
	}
         m_Button.SetBitmap(bit); //&lt;------ das bringt mir das Bild nicht auf den Button
	m_Test.SetBitmap(bit);
}
</code></pre>
<p>Überseh ich irgendwas wichtiges? Danke für Tips und Tricks</p>
<p>mfg blub <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/63497/bitmap-problem</link><generator>RSS for Node</generator><lastBuildDate>Thu, 04 Jun 2026 11:06:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/63497.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Feb 2004 13:33:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitmap-Problem on Mon, 02 Feb 2004 13:33:17 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>hab ein kleines Problem beim darstellen eines Bitmaps auf einem Button. Also das Bitmap wird aus einer Liste geladen und soll dann angezeigt werden. Bei einer PictureBox geht das ohne Problem nur auf dem Button krieg ich den nicht geladen mit SetBitmap. Hier mal der Code:</p>
<pre><code class="language-cpp">void  Bilder::DrawSelectedImage()
{

	int size = 128;
	CString	strPath;
	CBitmap bitmap,bit;
	BITMAP bm;

	// read the image file
	strPath = m_strImageDir + &quot;\\&quot; + m_VectorImageNames[m_nSelectedItem];
	bitmap.Attach(LoadImage(NULL,strPath,IMAGE_BITMAP,NULL,NULL,LR_LOADFROMFILE|LR_DEFAULTCOLOR|LR_DEFAULTSIZE));

	bitmap.GetObject(sizeof(bm), &amp;bm); 
	{ 
		CDC speicherDC; 
		speicherDC.CreateCompatibleDC(GetDC()); 
		speicherDC.SelectObject(&amp;bitmap); 

		CDC BmpDC; 
		BmpDC.CreateCompatibleDC(GetDC()); 
		bit.CreateCompatibleBitmap(GetDC(),size,size);
		BmpDC.SelectObject(&amp;bit); 

		BmpDC.SetStretchBltMode(HALFTONE);
			::SetBrushOrgEx(BmpDC.m_hDC,0,0,NULL);

		BmpDC.StretchBlt(0, 0,size,size,&amp;speicherDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); 
	}
         m_Button.SetBitmap(bit); //&lt;------ das bringt mir das Bild nicht auf den Button
	m_Test.SetBitmap(bit);
}
</code></pre>
<p>Überseh ich irgendwas wichtiges? Danke für Tips und Tricks</p>
<p>mfg blub <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/449602</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/449602</guid><dc:creator><![CDATA[blub]]></dc:creator><pubDate>Mon, 02 Feb 2004 13:33:17 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap-Problem on Mon, 02 Feb 2004 14:59:32 GMT]]></title><description><![CDATA[<p>Hallo,<br />
hast du im Eigenschaftendialog (doppelklick auf den Button im Gestaltungsmodus) von deinem Button &quot;Bitmap&quot; aktiviert ??<br />
Turbobrain</p>
]]></description><link>https://www.c-plusplus.net/forum/post/449697</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/449697</guid><dc:creator><![CDATA[turbobrain]]></dc:creator><pubDate>Mon, 02 Feb 2004 14:59:32 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap-Problem on Mon, 02 Feb 2004 15:06:24 GMT]]></title><description><![CDATA[<p>thx, aber ich werd das anders machen, hab grad die MSDN durchgeschaut und bei Codeproject gesucht und nix gefunden was mir zusagt. Die nächste Frage kommt betstimmt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>gruß blub <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/449708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/449708</guid><dc:creator><![CDATA[blub]]></dc:creator><pubDate>Mon, 02 Feb 2004 15:06:24 GMT</pubDate></item></channel></rss>