<?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 auf Dialog zeichnen - was geht hier schief?]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe einen Dialog, auf dem ich ein erst zur Laufzeit vorliegendes Bitmap zeichnen will.</p>
<p>Globale Varibalen:</p>
<pre><code class="language-cpp">CBitmap* my_pic_bitmap=NULL;
HWND     dlg_pic;
</code></pre>
<p>Funktionen:</p>
<pre><code class="language-cpp">VOID CopyImageToBitmap(ColorImage&amp; my_pic)
{ 
    my_pic.Resize(705,260);
    my_pic_bitmap=new CBitmap;
    my_pic_bitmap-&gt;CreateBitmap(my_pic.Width(),my_pic.Heigth(),1,24,NULL);

    BITMAP bm;
    my_pic_bitmap-&gt;GetObject( sizeof(BITMAP), &amp;bm );
    unsigned char *data = new unsigned char[bm.bmHeight*bm.bmWidthBytes];

    for (int y=0; y&lt;bm.bmHeight; ++y)
	for (int x=0; x&lt;bm.bmWidth; ++x)
		{data[(x*3)+(y*bm.bmWidthBytes)]   = (unsigned char)(*my_pic)(y,x).b;
		 data[(x*3)+(y*bm.bmWidthBytes)+1] = (unsigned char)(*my_pic)(y,x).g;
		 data[(x*3)+(y*bm.bmWidthBytes)+2] = (unsigned char)(*my_pic)(y,x).r;
		}

    //ofstream ofs(&quot;test.ppm&quot;,ios::binary);
    //my_pic.Store(ofs);
}

VOID DrawBitMapToDiaolog(HWND hDlg)
{ 	
   HBITMAP hbitmap = (*my_pic_bitmap).operator HBITMAP();
   dlg_pic = CreateWindowEx(NULL, &quot;STATIC&quot;, &quot;&quot;, WS_CHILD | WS_VISIBLE | WS_THICKFRAME | SS_BITMAP , 16, 70, 705, 260, hDlg, NULL, 0 , 0);
   SendMessage(dlg_pic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hbitmap );
}
</code></pre>
<p>Die auskommentierten Zeilen zum Speichern dienten zum Überprüfen, ob das ColorImage (eigener Typ) auch das richtige Bild enthält. Tut es.<br />
Das ganze wird übersetzt und läuft auch ohne Abzustürzen. Leider ist auf dem Dialog ein völlig falsches Bild dargestellt! Nicht das was ich sehen wollte, sondern ein quadratisches, in den die Windows Fenster-Steuer-icons (Minimieren,Maximieren,Schließen - jeweils gedrückt und ungedrückt ) Desweiteren sicnd die Icons aller geöffneten Programme in diesem Bild enthalten jeweils doppelt für aktiviertes Fenster und nicht aktiviertes Fenster ... alles schon sauber hintereinander. Meine Frage ist bloß: Wie kommen die in meine Bitmap?? Keine Ahnung, was geht hier schief?</p>
<p>Vielen Dank für sachdienliche Hinweise. <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/124513/bitmap-auf-dialog-zeichnen-was-geht-hier-schief</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 07:40:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124513.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 28 Oct 2005 09:26:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitmap auf Dialog zeichnen - was geht hier schief? on Fri, 28 Oct 2005 09:26:35 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe einen Dialog, auf dem ich ein erst zur Laufzeit vorliegendes Bitmap zeichnen will.</p>
<p>Globale Varibalen:</p>
<pre><code class="language-cpp">CBitmap* my_pic_bitmap=NULL;
HWND     dlg_pic;
</code></pre>
<p>Funktionen:</p>
<pre><code class="language-cpp">VOID CopyImageToBitmap(ColorImage&amp; my_pic)
{ 
    my_pic.Resize(705,260);
    my_pic_bitmap=new CBitmap;
    my_pic_bitmap-&gt;CreateBitmap(my_pic.Width(),my_pic.Heigth(),1,24,NULL);

    BITMAP bm;
    my_pic_bitmap-&gt;GetObject( sizeof(BITMAP), &amp;bm );
    unsigned char *data = new unsigned char[bm.bmHeight*bm.bmWidthBytes];

    for (int y=0; y&lt;bm.bmHeight; ++y)
	for (int x=0; x&lt;bm.bmWidth; ++x)
		{data[(x*3)+(y*bm.bmWidthBytes)]   = (unsigned char)(*my_pic)(y,x).b;
		 data[(x*3)+(y*bm.bmWidthBytes)+1] = (unsigned char)(*my_pic)(y,x).g;
		 data[(x*3)+(y*bm.bmWidthBytes)+2] = (unsigned char)(*my_pic)(y,x).r;
		}

    //ofstream ofs(&quot;test.ppm&quot;,ios::binary);
    //my_pic.Store(ofs);
}

VOID DrawBitMapToDiaolog(HWND hDlg)
{ 	
   HBITMAP hbitmap = (*my_pic_bitmap).operator HBITMAP();
   dlg_pic = CreateWindowEx(NULL, &quot;STATIC&quot;, &quot;&quot;, WS_CHILD | WS_VISIBLE | WS_THICKFRAME | SS_BITMAP , 16, 70, 705, 260, hDlg, NULL, 0 , 0);
   SendMessage(dlg_pic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hbitmap );
}
</code></pre>
<p>Die auskommentierten Zeilen zum Speichern dienten zum Überprüfen, ob das ColorImage (eigener Typ) auch das richtige Bild enthält. Tut es.<br />
Das ganze wird übersetzt und läuft auch ohne Abzustürzen. Leider ist auf dem Dialog ein völlig falsches Bild dargestellt! Nicht das was ich sehen wollte, sondern ein quadratisches, in den die Windows Fenster-Steuer-icons (Minimieren,Maximieren,Schließen - jeweils gedrückt und ungedrückt ) Desweiteren sicnd die Icons aller geöffneten Programme in diesem Bild enthalten jeweils doppelt für aktiviertes Fenster und nicht aktiviertes Fenster ... alles schon sauber hintereinander. Meine Frage ist bloß: Wie kommen die in meine Bitmap?? Keine Ahnung, was geht hier schief?</p>
<p>Vielen Dank für sachdienliche Hinweise. <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/902560</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902560</guid><dc:creator><![CDATA[esa_mmr]]></dc:creator><pubDate>Fri, 28 Oct 2005 09:26:35 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap auf Dialog zeichnen - was geht hier schief? on Fri, 28 Oct 2005 09:38:49 GMT]]></title><description><![CDATA[<p>Ich tippe auf falsche Abarbeitungsreihenfolge. Bzw solltest du &quot;my_pic_bitmap&quot; noch irgendwo erklären, daß es doch bitte die Bilddaten aus &quot;data&quot; abholen soll <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/902569</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902569</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 28 Oct 2005 09:38:49 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap auf Dialog zeichnen - was geht hier schief? on Fri, 28 Oct 2005 10:03:54 GMT]]></title><description><![CDATA[<p>Sorry, das war ein copy-and-paste Fehler. Im Programm lautet es</p>
<pre><code class="language-cpp">VOID CopyImageToBitmap(ColorImage&amp; my_pic) 
{ 
    my_pic.Resize(705,260); 
    my_pic_bitmap=new CBitmap; 
    my_pic_bitmap-&gt;CreateBitmap(my_pic.Width(),my_pic.Heigth(),1,24,NULL); 

    BITMAP bm; 
    my_pic_bitmap-&gt;GetObject( sizeof(BITMAP), &amp;bm ); 
    unsigned char *data = new unsigned char[bm.bmHeight*bm.bmWidthBytes]; 

    for (int y=0; y&lt;bm.bmHeight; ++y) 
    for (int x=0; x&lt;bm.bmWidth; ++x) 
        {data[(x*3)+(y*bm.bmWidthBytes)]   = (unsigned char)(*my_pic)(y,x).b; 
         data[(x*3)+(y*bm.bmWidthBytes)+1] = (unsigned char)(*my_pic)(y,x).g; 
         data[(x*3)+(y*bm.bmWidthBytes)+2] = (unsigned char)(*my_pic)(y,x).r; 
        } 

   my_pic_bitmap-&gt;SetBitmapBits((bm.bmHeight*bm.bmWidthBytes),data);
   delete [] data; 
    //ofstream ofs(&quot;test.ppm&quot;,ios::binary); 
    //my_pic.Store(ofs); 
}
</code></pre>
<p>Also daran liegt es wohl eher nicht. Wie kann ich überprüfen, ob in my_pic_bitmap das richtige steht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/902596</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902596</guid><dc:creator><![CDATA[esa_mmr]]></dc:creator><pubDate>Fri, 28 Oct 2005 10:03:54 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap auf Dialog zeichnen - was geht hier schief? on Fri, 28 Oct 2005 10:51:03 GMT]]></title><description><![CDATA[<p>Ok, weiterer Versuch. Das oben auskommentierte sichern des Bildes wieder reingenommen und nicht die Bitmap auf den Dialog übertragen, sondern das gesicherte Bild von Platte geladen ...</p>
<pre><code class="language-cpp">VOID DrawBitMapToDiaolog(HWND hDlg)
{ 	
   HANDLE hImage = LoadImage(NULL, &quot;c:\\test.bmp&quot;, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
   dlg_pic = CreateWindowEx(NULL, &quot;STATIC&quot;, NULL, WS_CHILD | WS_VISIBLE | WS_THICKFRAME | SS_BITMAP , 16, 70, 705, 260, hDlg, NULL, NULL , NULL);  
   SendMessage(dlg_pic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hImage );

   //HBITMAP hbitmap = (*my_pic_bitmap).operator HBITMAP();
   //spec_dlg_pic = CreateWindowEx(NULL, &quot;STATIC&quot;, NULL, WS_CHILD | WS_VISIBLE | WS_THICKFRAME | SS_BITMAP , 16, 70, 705, 260, hDlg, NULL, NULL , NULL);
   //SendMessage(dlg_pic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hbitmap );

}
</code></pre>
<p>Jetzt ist das richtige dargestellt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> Irgendetwas geht beim übertragen des Bildes auf die CBtimap und dann auf das Dialogelement schief ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/902636</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902636</guid><dc:creator><![CDATA[esa_mmr]]></dc:creator><pubDate>Fri, 28 Oct 2005 10:51:03 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap auf Dialog zeichnen - was geht hier schief? on Fri, 28 Oct 2005 12:43:15 GMT]]></title><description><![CDATA[<p>Also ich habe noch mal nachgeschaut ... in der CBitmap* my_pic_bitmap ist definitiv das richtige drin. Der Fehler kann nur beim Übertragen auf den Dialog zustandekommen ... <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="😕"
    /> Hilfe!</p>
<p>Viele Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/902768</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902768</guid><dc:creator><![CDATA[esa_mmr]]></dc:creator><pubDate>Fri, 28 Oct 2005 12:43:15 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap auf Dialog zeichnen - was geht hier schief? on Fri, 28 Oct 2005 12:52:27 GMT]]></title><description><![CDATA[<p>*schaut sich an, was für eine Nachricht da überhaupt gesendet wird*</p>
<p>MSDN schrieb:</p>
<blockquote>
<p>An application sends an STM_SETIMAGE message to associate a new image with a static control.</p>
</blockquote>
<p>Ist ein Dialog ein &quot;static control&quot;? Nach meiner Einschätzung nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Du solltest vielleicht versuchen, das Bild selber zu zeichnen, indem du WM_PAINT abfängst und auswertest (etwas weiter unten im Board dürfte auch ein Quelltext dazu sein).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/902778</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902778</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 28 Oct 2005 12:52:27 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap auf Dialog zeichnen - was geht hier schief? on Fri, 28 Oct 2005 13:09:09 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> dagegen:</p>
<pre><code class="language-cpp">);
   dlg_pic = CreateWindowEx(NULL, &quot;STATIC&quot;, NULL, WS_CHILD | WS_VISIBLE | WS_THICKFRAME | SS_BITMAP , 16, 70, 705, 260, hDlg, NULL, NULL , NULL);  
   SendMessage(dlg_pic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hImage );
</code></pre>
<p>STM_SETIMAGE wird an dlg_pic gesendet, und das ist doch als &quot;STATIC&quot; gebastelt ... ?<br />
Außerdem würde es dann wohl auch beim laden des Bildes von Platte nicht funktionieren ... tut es aber <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/902790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/902790</guid><dc:creator><![CDATA[esa_mmr]]></dc:creator><pubDate>Fri, 28 Oct 2005 13:09:09 GMT</pubDate></item></channel></rss>