<?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[Fehler in einfacher Anwendung]]></title><description><![CDATA[<p>Ich habe folgende Anwendung geschrieben:</p>
<pre><code class="language-cpp">//CCreativeButtons
#include &lt;windows.h&gt;

class CCreativeButtons
{
public:
	bool CreateButton(HDC hdc,HWND hwnd, HBITMAP bmp_off, HBITMAP bmp_on, bool clickbutton); 
};

bool CCreativeButtons::CreateButton(HDC hdc,HWND hwnd, HBITMAP bmp_off, HBITMAP bmp_on, bool clickbutton)
{
	//variables
	HDC bmp_hdc = CreateCompatibleDC(NULL);
	hdc = GetDC(hwnd);
	//show bmp_off
	SelectObject(bmp_hdc, bmp_off);
	BitBlt(hdc, 100, 100, 100, 100, bmp_hdc, 0, 0, SRCCOPY);

	return(true);
}

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hI, HINSTANCE hPI, LPSTR lpCmdLine, int iCmdShow)
{
	WNDCLASS wc;
	char szName[] = &quot;CreativeButtons&quot;;

	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.hCursor = LoadCursor(0, IDC_ARROW);
	wc.hIcon = LoadIcon(0, IDI_WINLOGO);
	wc.hInstance = hI;
	wc.lpfnWndProc = WndProc;
	wc.lpszClassName = szName;
	wc.lpszMenuName = 0;
	wc.style = CS_HREDRAW | CS_VREDRAW;

	RegisterClass(&amp;wc);

	HWND hwnd = CreateWindow(szName, &quot;CreativeButtonTest&quot;, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
								CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hI, 0);

	ShowWindow(hwnd, iCmdShow);
	UpdateWindow(hwnd);

	MSG msg;

	while(GetMessage(&amp;msg, 0, 0, 0))
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}

	UnregisterClass(szName, hI);

	return(msg.wParam);
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	CCreativeButtons buttoninstance;
	HDC hdc = GetDC(hwnd);
	HBITMAP bmp_on = 0;
	HBITMAP bmp_off = (HBITMAP)LoadImage((HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), &quot;C:\\bmp_off.bmp&quot;,IMAGE_BITMAP,0, 0, LR_LOADFROMFILE); 

	switch(message)
	{
	case WM_PAINT:
	//show bmp_off
		buttoninstance.CreateButton(hdc,hwnd, bmp_off, bmp_on, true);
		return(0);
	case WM_DESTROY:
		PostQuitMessage(0);
		return(0);
	}

	return(DefWindowProc(hwnd, message, wParam, lParam));
}
</code></pre>
<p>Wenn ich das Programm nun aber ausführe und das Fenster verschiebe bleibt es hängen, ich verstehe aber nicht wieso. Könnte mir bitte jemand den Fehler nennen und erklären?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/85965/fehler-in-einfacher-anwendung</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 21:17:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/85965.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Sep 2004 14:11:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler in einfacher Anwendung on Tue, 14 Sep 2004 14:11:21 GMT]]></title><description><![CDATA[<p>Ich habe folgende Anwendung geschrieben:</p>
<pre><code class="language-cpp">//CCreativeButtons
#include &lt;windows.h&gt;

class CCreativeButtons
{
public:
	bool CreateButton(HDC hdc,HWND hwnd, HBITMAP bmp_off, HBITMAP bmp_on, bool clickbutton); 
};

bool CCreativeButtons::CreateButton(HDC hdc,HWND hwnd, HBITMAP bmp_off, HBITMAP bmp_on, bool clickbutton)
{
	//variables
	HDC bmp_hdc = CreateCompatibleDC(NULL);
	hdc = GetDC(hwnd);
	//show bmp_off
	SelectObject(bmp_hdc, bmp_off);
	BitBlt(hdc, 100, 100, 100, 100, bmp_hdc, 0, 0, SRCCOPY);

	return(true);
}

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hI, HINSTANCE hPI, LPSTR lpCmdLine, int iCmdShow)
{
	WNDCLASS wc;
	char szName[] = &quot;CreativeButtons&quot;;

	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.hCursor = LoadCursor(0, IDC_ARROW);
	wc.hIcon = LoadIcon(0, IDI_WINLOGO);
	wc.hInstance = hI;
	wc.lpfnWndProc = WndProc;
	wc.lpszClassName = szName;
	wc.lpszMenuName = 0;
	wc.style = CS_HREDRAW | CS_VREDRAW;

	RegisterClass(&amp;wc);

	HWND hwnd = CreateWindow(szName, &quot;CreativeButtonTest&quot;, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
								CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hI, 0);

	ShowWindow(hwnd, iCmdShow);
	UpdateWindow(hwnd);

	MSG msg;

	while(GetMessage(&amp;msg, 0, 0, 0))
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}

	UnregisterClass(szName, hI);

	return(msg.wParam);
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	CCreativeButtons buttoninstance;
	HDC hdc = GetDC(hwnd);
	HBITMAP bmp_on = 0;
	HBITMAP bmp_off = (HBITMAP)LoadImage((HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), &quot;C:\\bmp_off.bmp&quot;,IMAGE_BITMAP,0, 0, LR_LOADFROMFILE); 

	switch(message)
	{
	case WM_PAINT:
	//show bmp_off
		buttoninstance.CreateButton(hdc,hwnd, bmp_off, bmp_on, true);
		return(0);
	case WM_DESTROY:
		PostQuitMessage(0);
		return(0);
	}

	return(DefWindowProc(hwnd, message, wParam, lParam));
}
</code></pre>
<p>Wenn ich das Programm nun aber ausführe und das Fenster verschiebe bleibt es hängen, ich verstehe aber nicht wieso. Könnte mir bitte jemand den Fehler nennen und erklären?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/607009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607009</guid><dc:creator><![CDATA[The_incredible_Guest]]></dc:creator><pubDate>Tue, 14 Sep 2004 14:11:21 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in einfacher Anwendung on Tue, 14 Sep 2004 14:17:12 GMT]]></title><description><![CDATA[<p>Ich habe den Fehler schon entdeckt:<br />
Als ich &quot;BeginPaint()&quot; und &quot;EndPaint()&quot; unter &quot;case WM_PAINT:&quot; verwendet habe lief alles wie erwünscht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/607017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607017</guid><dc:creator><![CDATA[The_incredible_Guest]]></dc:creator><pubDate>Tue, 14 Sep 2004 14:17:12 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in einfacher Anwendung on Tue, 14 Sep 2004 15:24:12 GMT]]></title><description><![CDATA[<p>Erstelle bitte nicht jedesmal bei WM_PAINT einen neuen Button <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="⚠"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/607092</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607092</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 14 Sep 2004 15:24:12 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in einfacher Anwendung on Tue, 14 Sep 2004 15:29:04 GMT]]></title><description><![CDATA[<p>Dort wird ja gar keine Button erstellt sondern nur gezeichnet. :p</p>
<p>The_incredible_Guest: Du solltest dich unbedingt mit der GDI Speicherverwaltung beschäftigen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/607097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607097</guid><dc:creator><![CDATA[lagger]]></dc:creator><pubDate>Tue, 14 Sep 2004 15:29:04 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in einfacher Anwendung on Tue, 14 Sep 2004 15:34:12 GMT]]></title><description><![CDATA[<p>lagger schrieb:</p>
<blockquote>
<p>Dort wird ja gar keine Button erstellt sondern nur gezeichnet. :p</p>
</blockquote>
<p>Stimm ja, hatte mir das gar nicht so genau angeschaut <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="🙄"
    /> aber CreateButton ist dann auch nicht der optimale Name für diese Funktion <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/607101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607101</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 14 Sep 2004 15:34:12 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in einfacher Anwendung on Wed, 29 Dec 2004 15:56:52 GMT]]></title><description><![CDATA[<p>Die Klasse ist ja auch noch lange nicht fertig ihr Heinzen, das ist ja erstmal nur die grafische Ausgabe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/682736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/682736</guid><dc:creator><![CDATA[The_incredible_Guest]]></dc:creator><pubDate>Wed, 29 Dec 2004 15:56:52 GMT</pubDate></item></channel></rss>