<?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 (Windows CE)]]></title><description><![CDATA[<p>Hallo,<br />
ich schreibe momentan ein Programm bei dem verschieden Elemente visualisiert werden sollen (Linien, Bitmaps, Rechtecke,...), dazu verwende ich Microsoft eMbedded Visual C++.<br />
Jetzt habe ich ein Problem. Ich habe in einem Testprogramm ein Bitmap in die Resource geladen und es dann mit der LoadBitmap-Funktion auch darstellen können. Jedoch habe ich jetzt das Problem, dass das Bitmap nicht dargestellt wird. Habe eine Klasse SIControl erstellt, von der die Klassen erben (SILine, SIBitmap,...).<br />
Die Linien werden gezeichnet und dargestellt nur eben nicht das Bitmap. <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="😕"
    /> <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>
<p>Hier zuerst der Code in dem die Klassen definiert sind:</p>
<pre><code class="language-cpp">// SIControl.cpp: implementation of the SIControl class.
//
//////////////////////////////////////////////////////////////////////
#include &quot;stdafx.h&quot;
#include &lt;windows.h&gt;
#include &quot;resource.h&quot;
#include &lt;Commctrl.h&gt;
#include &quot;SIControl.h&quot;
#include &quot;SIBitmap.h&quot;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SIControl::SIControl()
{

}

SIControl::~SIControl()
{

}

//////////////////////////////////////////////////////////////////////
// SILine Class
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SILine::SILine(int p_Xstart, int p_Ystart, int p_Xend, int p_Yend, COLORREF  p_penColor,
			   int p_penWidth, int p_penDashed, int p_Dashlen, 
                                                   int p_Dashbreak)
{
	Xstart = p_Xstart;
	Ystart = p_Ystart;
	Xend = p_Xend;
	Yend = p_Yend;
	penColor = p_penColor;
	penWidth = p_penWidth;
	penDashed = p_penDashed ;
	Dashlen = p_Dashlen;
	Dashbreak = p_Dashbreak;
}

SILine::~SILine()
{

}

BOOL SILine::Paint(HDC hdc)
{

	HPEN  mypen;
	if(penDashed == 0){
		mypen = CreatePen(PS_SOLID,penWidth,penColor);
	}else{
		mypen = CreatePen(PS_DASH,1,penColor);
	}
	SelectObject(hdc,mypen);

	POINT p[2];
	p[0].x=Xstart;
	p[0].y=Ystart;
	p[1].x=Xend;
	p[1].y=Yend;

	Polyline(hdc,p,2);

	DeleteObject(mypen);
	return	TRUE;
}

//////////////////////////////////////////////////////////////////////
// SIBitmap Class
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SIBitmap::SIBitmap(int p_Adress, int p_Align, int p_Autosize, int p_Stretch,
				   int p_BitmapResourceBit0, 
                                                                   int p_BitmapResourceBit1,
                                                                   int p_BitmapFileBit0,
				   int p_BitmapFileBit1, int p_Center, 
                                                                   int p_BitNr, int p_BitmapWidth, 
				   int p_SubsheetEnable, int p_HelpActivate0, 
                                                                   int p_HelpActivate1, 
				   int p_HelpKontext0, int p_HelpKontext1, 
                                                                   int p_Height, int p_Left, 
				   int p_Top, BOOL p_Transparent,
                                                                   int p_Variable)
{
	Adress = p_Adress;
	Align = p_Align;
	Autosize = p_Autosize;
	Stretch = p_Stretch;
	BitmapResourceBit0 = p_BitmapResourceBit0;
	BitmapResourceBit1 = p_BitmapResourceBit1;
	BitmapFileBit0 = p_BitmapFileBit0;
	BitmapFileBit1 = p_BitmapFileBit1;
	Center = p_Center;
	BitNr = p_BitNr;
	BitmapWidth = p_BitmapWidth;
	SubsheetEnable = p_SubsheetEnable;
	HelpActivate0 = p_HelpActivate0;
	HelpActivate1 = p_HelpActivate1;
	HelpKontext0 = p_HelpKontext0;
	HelpKontext1 = p_HelpKontext1;
	Height = p_Height;
	Left = p_Left;
	Top = p_Top;
	Transparent = p_Transparent;
	Variable = p_Variable;
}

SIBitmap::~SIBitmap()
{

}
BOOL SIBitmap::Paint(HDC hdc)
{
	PAINTSTRUCT ps;
	HINSTANCE g_hInst;
	HDC memory = CreateCompatibleDC(hdc);
	HBITMAP bild = LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP1)); 
	SelectObject(memory, bild);
	BitBlt(ps.hdc, 10,10, 50,50, memory, 0, 0, SRCCOPY);
	DeleteObject(bild);
	return TRUE;
}
</code></pre>
<p>Hier ist ein weiterer Codeschnipsel, indem die Funktionen in das Fenster eingefügt werden:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc (HWND hwnd, UINT umsg, WPARAM wParam, 
                          LPARAM lParam)
{

  int wmId, wmEvent;

  switch (umsg)
  {
    // Add cases such as WM_CREATE, WM_COMMAND, WM_PAINT if you don't 
    // want to pass these messages along for default processing.

    case WM_CLOSE:
      DestroyWindow (hwnd);
      return 0;

    case WM_DESTROY:
	  CommandBar_Destroy(hwndCB);
      PostQuitMessage (0);
      return 0;

	case WM_CREATE:
			break;
	case WM_COMMAND:
			break;
	case WM_SIZE:
   // Tell the command bar to resize itself to fill the top of the
		break;
	case WM_PAINT:

		PAINTSTRUCT ps;
        HDC hdc;
        COLORREF crTxt, crBk;
		RECT rcClient; 
        hdc = BeginPaint(hwnd, &amp;ps);
		GetClientRect(hwnd,&amp;rcClient); 

		SILine* pLine = new SILine(0,130,100,30,RGB(255,0,0),2,false,1,2);
		pLine-&gt;Paint(ps.hdc);
		delete pLine;

		pLine = new SILine(10,130,220,130,RGB(255,0,255),20,true,1,2);
		pLine-&gt;Paint(ps.hdc);
		delete pLine;

		SIBitmap* pBitmap = new SIBitmap(1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 100,
                                                                                    0, 0, 0, 0, 0, 100, 300, 100, 
                                                                                    true, 0);
		pBitmap-&gt;Paint(ps.hdc);
		delete pBitmap;

		EndPaint(hwnd, &amp;ps);

        break;
  }
  return DefWindowProc (hwnd, umsg, wParam, lParam);
}
</code></pre>
<p>Ich bekomme auch keine Fehlermeldung beim Kompilieren oder Bilden.<br />
Hoffe, dass mir jemand helfen kann.</p>
<p>Mfg und schon einmal vielen Dank im voraus<br />
Heike</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/184897/bitmap-windows-ce</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 11:39:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/184897.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Jun 2007 07:52:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitmap (Windows CE) on Wed, 20 Jun 2007 07:52:22 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich schreibe momentan ein Programm bei dem verschieden Elemente visualisiert werden sollen (Linien, Bitmaps, Rechtecke,...), dazu verwende ich Microsoft eMbedded Visual C++.<br />
Jetzt habe ich ein Problem. Ich habe in einem Testprogramm ein Bitmap in die Resource geladen und es dann mit der LoadBitmap-Funktion auch darstellen können. Jedoch habe ich jetzt das Problem, dass das Bitmap nicht dargestellt wird. Habe eine Klasse SIControl erstellt, von der die Klassen erben (SILine, SIBitmap,...).<br />
Die Linien werden gezeichnet und dargestellt nur eben nicht das Bitmap. <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="😕"
    /> <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>
<p>Hier zuerst der Code in dem die Klassen definiert sind:</p>
<pre><code class="language-cpp">// SIControl.cpp: implementation of the SIControl class.
//
//////////////////////////////////////////////////////////////////////
#include &quot;stdafx.h&quot;
#include &lt;windows.h&gt;
#include &quot;resource.h&quot;
#include &lt;Commctrl.h&gt;
#include &quot;SIControl.h&quot;
#include &quot;SIBitmap.h&quot;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SIControl::SIControl()
{

}

SIControl::~SIControl()
{

}

//////////////////////////////////////////////////////////////////////
// SILine Class
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SILine::SILine(int p_Xstart, int p_Ystart, int p_Xend, int p_Yend, COLORREF  p_penColor,
			   int p_penWidth, int p_penDashed, int p_Dashlen, 
                                                   int p_Dashbreak)
{
	Xstart = p_Xstart;
	Ystart = p_Ystart;
	Xend = p_Xend;
	Yend = p_Yend;
	penColor = p_penColor;
	penWidth = p_penWidth;
	penDashed = p_penDashed ;
	Dashlen = p_Dashlen;
	Dashbreak = p_Dashbreak;
}

SILine::~SILine()
{

}

BOOL SILine::Paint(HDC hdc)
{

	HPEN  mypen;
	if(penDashed == 0){
		mypen = CreatePen(PS_SOLID,penWidth,penColor);
	}else{
		mypen = CreatePen(PS_DASH,1,penColor);
	}
	SelectObject(hdc,mypen);

	POINT p[2];
	p[0].x=Xstart;
	p[0].y=Ystart;
	p[1].x=Xend;
	p[1].y=Yend;

	Polyline(hdc,p,2);

	DeleteObject(mypen);
	return	TRUE;
}

//////////////////////////////////////////////////////////////////////
// SIBitmap Class
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SIBitmap::SIBitmap(int p_Adress, int p_Align, int p_Autosize, int p_Stretch,
				   int p_BitmapResourceBit0, 
                                                                   int p_BitmapResourceBit1,
                                                                   int p_BitmapFileBit0,
				   int p_BitmapFileBit1, int p_Center, 
                                                                   int p_BitNr, int p_BitmapWidth, 
				   int p_SubsheetEnable, int p_HelpActivate0, 
                                                                   int p_HelpActivate1, 
				   int p_HelpKontext0, int p_HelpKontext1, 
                                                                   int p_Height, int p_Left, 
				   int p_Top, BOOL p_Transparent,
                                                                   int p_Variable)
{
	Adress = p_Adress;
	Align = p_Align;
	Autosize = p_Autosize;
	Stretch = p_Stretch;
	BitmapResourceBit0 = p_BitmapResourceBit0;
	BitmapResourceBit1 = p_BitmapResourceBit1;
	BitmapFileBit0 = p_BitmapFileBit0;
	BitmapFileBit1 = p_BitmapFileBit1;
	Center = p_Center;
	BitNr = p_BitNr;
	BitmapWidth = p_BitmapWidth;
	SubsheetEnable = p_SubsheetEnable;
	HelpActivate0 = p_HelpActivate0;
	HelpActivate1 = p_HelpActivate1;
	HelpKontext0 = p_HelpKontext0;
	HelpKontext1 = p_HelpKontext1;
	Height = p_Height;
	Left = p_Left;
	Top = p_Top;
	Transparent = p_Transparent;
	Variable = p_Variable;
}

SIBitmap::~SIBitmap()
{

}
BOOL SIBitmap::Paint(HDC hdc)
{
	PAINTSTRUCT ps;
	HINSTANCE g_hInst;
	HDC memory = CreateCompatibleDC(hdc);
	HBITMAP bild = LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP1)); 
	SelectObject(memory, bild);
	BitBlt(ps.hdc, 10,10, 50,50, memory, 0, 0, SRCCOPY);
	DeleteObject(bild);
	return TRUE;
}
</code></pre>
<p>Hier ist ein weiterer Codeschnipsel, indem die Funktionen in das Fenster eingefügt werden:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc (HWND hwnd, UINT umsg, WPARAM wParam, 
                          LPARAM lParam)
{

  int wmId, wmEvent;

  switch (umsg)
  {
    // Add cases such as WM_CREATE, WM_COMMAND, WM_PAINT if you don't 
    // want to pass these messages along for default processing.

    case WM_CLOSE:
      DestroyWindow (hwnd);
      return 0;

    case WM_DESTROY:
	  CommandBar_Destroy(hwndCB);
      PostQuitMessage (0);
      return 0;

	case WM_CREATE:
			break;
	case WM_COMMAND:
			break;
	case WM_SIZE:
   // Tell the command bar to resize itself to fill the top of the
		break;
	case WM_PAINT:

		PAINTSTRUCT ps;
        HDC hdc;
        COLORREF crTxt, crBk;
		RECT rcClient; 
        hdc = BeginPaint(hwnd, &amp;ps);
		GetClientRect(hwnd,&amp;rcClient); 

		SILine* pLine = new SILine(0,130,100,30,RGB(255,0,0),2,false,1,2);
		pLine-&gt;Paint(ps.hdc);
		delete pLine;

		pLine = new SILine(10,130,220,130,RGB(255,0,255),20,true,1,2);
		pLine-&gt;Paint(ps.hdc);
		delete pLine;

		SIBitmap* pBitmap = new SIBitmap(1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 100,
                                                                                    0, 0, 0, 0, 0, 100, 300, 100, 
                                                                                    true, 0);
		pBitmap-&gt;Paint(ps.hdc);
		delete pBitmap;

		EndPaint(hwnd, &amp;ps);

        break;
  }
  return DefWindowProc (hwnd, umsg, wParam, lParam);
}
</code></pre>
<p>Ich bekomme auch keine Fehlermeldung beim Kompilieren oder Bilden.<br />
Hoffe, dass mir jemand helfen kann.</p>
<p>Mfg und schon einmal vielen Dank im voraus<br />
Heike</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1309648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1309648</guid><dc:creator><![CDATA[Heike711]]></dc:creator><pubDate>Wed, 20 Jun 2007 07:52:22 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap (Windows CE) on Wed, 20 Jun 2007 12:30:12 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-403.html" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-15.html" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-4.html" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1309880</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1309880</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 20 Jun 2007 12:30:12 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap (Windows CE) on Wed, 20 Jun 2007 16:40:46 GMT]]></title><description><![CDATA[<p>Erstmal vorweg: Du solltest bei SelectObject/DeleteObject dafür sorgen, dass das vorherige Objekt wieder eingesetzt, zum Beispiel so (hergott wie oft wir das jetzt schon hatten <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /> ):</p>
<pre><code class="language-cpp">// ...
HPEN hpOldPen = SelectObject(hdcMem, CreatePen(...));
// ...
DeleteObject(SelectObject(hdcMem, hpOldPen));
// ...
</code></pre>
<p>Hier sind Deine Fehler:</p>
<pre><code class="language-cpp">BOOL SIBitmap::Paint(HDC hdc)
{
    PAINTSTRUCT ps;
    HINSTANCE g_hInst;
    HDC memory = CreateCompatibleDC(hdc);
    HBITMAP bild = LoadBitmap(g_hInst,MAKEINTRESOURCE(IDB_BITMAP1));
    SelectObject(memory, bild);
    BitBlt(ps.hdc, 10,10, 50,50, memory, 0, 0, SRCCOPY);
    DeleteObject(bild);
    return TRUE;
}
</code></pre>
<p><strong>1.:</strong> 'ps' wird definiert und verwendet (siehe <em>BitBlt</em>) aber nicht initialisiert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /><br />
<strong>2.:</strong> 'g_hInst' wird definiert und ebenfalls nicht initialisiert, trotz Verwendung bei <em>LoadBitmap</em>, der Anfangswert ist also undefiniert - Wie soll da auch irgendetwas gezeichnet :p . Dies hättest Du auch herausbekommen, wenn Du den Return Wert von <em>LoadBitmap</em> (also den Inhalt von 'bild') überprüft hättest ( <code>!= NULL</code> ).<br />
<strong>3.:</strong> 'memory' wird nicht freigegeben.<br />
<strong>4.:</strong> Siehe Hinweis zu SelectObject, oben.</p>
<p>Warum hat die Funktion eigentlich den Return-Typ <em>BOOL</em> ? Dieser ist doch sowieso immer <em>TRUE</em> <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>
<p>PS: Warum allokierst Du die Objekte unter WM_PAINT dynamisch (new/delete) ? Das ist überflüssig und fehleranfällig; es reicht doch auf dem Funktionsstack.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1310094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1310094</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Wed, 20 Jun 2007 16:40:46 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap (Windows CE) on Fri, 29 Jun 2007 12:56:07 GMT]]></title><description><![CDATA[<p>Danke für deine Antwort.<br />
Habe zuerst mal die DeleteFunktion geändert, sieht jetzt so aus:</p>
<pre><code class="language-cpp">DeleteObject(memory);
</code></pre>
<p>Jetzt funktioniert alles.</p>
<p>Vielen Danke für die Hilfe.<br />
Lieben Gruß Heike</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1314969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1314969</guid><dc:creator><![CDATA[Heike711]]></dc:creator><pubDate>Fri, 29 Jun 2007 12:56:07 GMT</pubDate></item></channel></rss>