<?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[Flackern bei Fenster neu Zeichnen]]></title><description><![CDATA[<p>Hi @ All.</p>
<p>ich habe ein fenster, dass sich per SetTimer aktualisieren soll.<br />
nun möchte ich aber, dass der alte inhalt nicht unter dem Neuen liegt. wie soll ich das tun? das flackert dauernt!!!</p>
<pre><code class="language-cpp">// At first define for including the windows headers
#define _WIN32_WINNT 0x0500
#include &lt;windows.h&gt;

// C RunTime Header Files
#include &lt;stdlib.h&gt;
#include &lt;malloc.h&gt;
#include &lt;memory.h&gt;
#include &lt;tchar.h&gt;

#include &lt;math.h&gt;

// Local Header Files

#include &lt;commdlg.h&gt;
#include &lt;ocidl.h&gt;
#include &lt;olectl.h&gt;
#include &lt;crtdbg.h&gt;

float Angle = 0;

// The spiral draw function
BOOL Spiral(HDC hdc, int x, int y, int cx, int cy, int rot, int repeat)
{
	float angle = rot;
	float radius;
	float quality;

	if (cx &gt;= cy) 
	{
		quality = (float)cx/(float)400*(float)600;
	}
	else
	{
		 quality = (float)cy/(float)400*(float)600;
	}
	int px,py;

	MoveToEx(hdc,x,y,NULL);

	for (radius = 0; radius &lt;= 1; radius += (float)1/(float)quality)
	{
		px = (float)x+(float)sin((float)angle*(float)3.14159265358979323846/(float)180)*(float)radius*(float)cx/(float)2;
		py = (float)x-(float)cos((float)angle*(float)3.14159265358979323846/(float)180)*(float)radius*(float)cy/(float)2;
		LineTo(hdc,px,py);
		angle = rot + ((float)radius/(float)1*(float)repeat*(float)360);
	}
	return true;
}

// The Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HBRUSH hBrush;
	HPEN hPen;
	HDC hdc;
	RECT rect;

	switch (msg)
	{
	case WM_CREATE:
		break;
	case WM_PAINT:
		GetClientRect(hwnd,&amp;rect);
		hdc = BeginPaint(hwnd, &amp;ps);
		hBrush = CreateSolidBrush(RGB(255,255,255));
		hPen = CreatePen(PS_SOLID,15,RGB(0,0,0));

		SelectObject(hdc,hBrush);
		SelectObject(hdc,hPen);

		Spiral(hdc,rect.left+(rect.right-rect.left)/2,rect.top+(rect.bottom-rect.top)/2,(rect.right-rect.left)*1.5,(rect.bottom-rect.top)*1.5,Angle,10);

		EndPaint(hwnd, &amp;ps);
		break;
	case WM_TIMER:
		Angle += 10;
		InvalidateRect(hwnd,NULL,true);
		break;
	case WM_CLOSE:
		DestroyWindow(hwnd);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
					LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX wc;
	HWND hwnd;
	MSG Msg;
	static char appName[] = &quot;Your Application&quot;;

	// Registering the Window Class
	wc.cbSize		 = sizeof(WNDCLASSEX);
	wc.style		 = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc	 = WndProc;
	wc.cbClsExtra	 = 0;
	wc.cbWndExtra	 = 0;
	wc.hInstance	 = hInstance;
	wc.hIcon		 = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = appName;
	wc.hIconSm		 = LoadIcon(NULL, IDI_APPLICATION);

	if (!RegisterClassEx(&amp;wc))
	{
		MessageBox(NULL, &quot;Window Registration Failed!&quot;, &quot;Error!&quot;,
			MB_ICONERROR | MB_OK);
		return 0;
	}
	// Creating the Window
	hwnd = CreateWindowEx(
		//WS_EX_OVERLAPPEDWINDOW,
		WS_EX_CLIENTEDGE | WS_EX_TOPMOST,
		appName,
		&quot;Hypnotic&quot;,
		//WS_OVERLAPPEDWINDOW,
		WS_BORDER,
		CW_USEDEFAULT, CW_USEDEFAULT, 800, 800,
		NULL, NULL, hInstance, NULL);

	if (hwnd == NULL)
	{
		MessageBox(NULL, &quot;Window Creation Failed!&quot;, &quot;Error&quot;,
			MB_ICONERROR | MB_OK);
		return 0;
	}

	ShowWindow(hwnd, nCmdShow);

	SetTimer(hwnd,NULL,25,NULL);

	UpdateWindow(hwnd);

	// The Message Loop
	while (GetMessage(&amp;Msg, NULL, 0, 0) &gt; 0)
	{
		TranslateMessage(&amp;Msg);
		DispatchMessage(&amp;Msg);
	}
	return int(Msg.wParam);
}
</code></pre>
<p>danke..</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/189381/flackern-bei-fenster-neu-zeichnen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 02 Jul 2026 06:13:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/189381.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Aug 2007 10:36:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Flackern bei Fenster neu Zeichnen on Sun, 12 Aug 2007 10:50:49 GMT]]></title><description><![CDATA[<p>Hi @ All.</p>
<p>ich habe ein fenster, dass sich per SetTimer aktualisieren soll.<br />
nun möchte ich aber, dass der alte inhalt nicht unter dem Neuen liegt. wie soll ich das tun? das flackert dauernt!!!</p>
<pre><code class="language-cpp">// At first define for including the windows headers
#define _WIN32_WINNT 0x0500
#include &lt;windows.h&gt;

// C RunTime Header Files
#include &lt;stdlib.h&gt;
#include &lt;malloc.h&gt;
#include &lt;memory.h&gt;
#include &lt;tchar.h&gt;

#include &lt;math.h&gt;

// Local Header Files

#include &lt;commdlg.h&gt;
#include &lt;ocidl.h&gt;
#include &lt;olectl.h&gt;
#include &lt;crtdbg.h&gt;

float Angle = 0;

// The spiral draw function
BOOL Spiral(HDC hdc, int x, int y, int cx, int cy, int rot, int repeat)
{
	float angle = rot;
	float radius;
	float quality;

	if (cx &gt;= cy) 
	{
		quality = (float)cx/(float)400*(float)600;
	}
	else
	{
		 quality = (float)cy/(float)400*(float)600;
	}
	int px,py;

	MoveToEx(hdc,x,y,NULL);

	for (radius = 0; radius &lt;= 1; radius += (float)1/(float)quality)
	{
		px = (float)x+(float)sin((float)angle*(float)3.14159265358979323846/(float)180)*(float)radius*(float)cx/(float)2;
		py = (float)x-(float)cos((float)angle*(float)3.14159265358979323846/(float)180)*(float)radius*(float)cy/(float)2;
		LineTo(hdc,px,py);
		angle = rot + ((float)radius/(float)1*(float)repeat*(float)360);
	}
	return true;
}

// The Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HBRUSH hBrush;
	HPEN hPen;
	HDC hdc;
	RECT rect;

	switch (msg)
	{
	case WM_CREATE:
		break;
	case WM_PAINT:
		GetClientRect(hwnd,&amp;rect);
		hdc = BeginPaint(hwnd, &amp;ps);
		hBrush = CreateSolidBrush(RGB(255,255,255));
		hPen = CreatePen(PS_SOLID,15,RGB(0,0,0));

		SelectObject(hdc,hBrush);
		SelectObject(hdc,hPen);

		Spiral(hdc,rect.left+(rect.right-rect.left)/2,rect.top+(rect.bottom-rect.top)/2,(rect.right-rect.left)*1.5,(rect.bottom-rect.top)*1.5,Angle,10);

		EndPaint(hwnd, &amp;ps);
		break;
	case WM_TIMER:
		Angle += 10;
		InvalidateRect(hwnd,NULL,true);
		break;
	case WM_CLOSE:
		DestroyWindow(hwnd);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
					LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX wc;
	HWND hwnd;
	MSG Msg;
	static char appName[] = &quot;Your Application&quot;;

	// Registering the Window Class
	wc.cbSize		 = sizeof(WNDCLASSEX);
	wc.style		 = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc	 = WndProc;
	wc.cbClsExtra	 = 0;
	wc.cbWndExtra	 = 0;
	wc.hInstance	 = hInstance;
	wc.hIcon		 = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = appName;
	wc.hIconSm		 = LoadIcon(NULL, IDI_APPLICATION);

	if (!RegisterClassEx(&amp;wc))
	{
		MessageBox(NULL, &quot;Window Registration Failed!&quot;, &quot;Error!&quot;,
			MB_ICONERROR | MB_OK);
		return 0;
	}
	// Creating the Window
	hwnd = CreateWindowEx(
		//WS_EX_OVERLAPPEDWINDOW,
		WS_EX_CLIENTEDGE | WS_EX_TOPMOST,
		appName,
		&quot;Hypnotic&quot;,
		//WS_OVERLAPPEDWINDOW,
		WS_BORDER,
		CW_USEDEFAULT, CW_USEDEFAULT, 800, 800,
		NULL, NULL, hInstance, NULL);

	if (hwnd == NULL)
	{
		MessageBox(NULL, &quot;Window Creation Failed!&quot;, &quot;Error&quot;,
			MB_ICONERROR | MB_OK);
		return 0;
	}

	ShowWindow(hwnd, nCmdShow);

	SetTimer(hwnd,NULL,25,NULL);

	UpdateWindow(hwnd);

	// The Message Loop
	while (GetMessage(&amp;Msg, NULL, 0, 0) &gt; 0)
	{
		TranslateMessage(&amp;Msg);
		DispatchMessage(&amp;Msg);
	}
	return int(Msg.wParam);
}
</code></pre>
<p>danke..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1343100</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1343100</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 12 Aug 2007 10:50:49 GMT</pubDate></item><item><title><![CDATA[Reply to Flackern bei Fenster neu Zeichnen on Sun, 12 Aug 2007 12:10:30 GMT]]></title><description><![CDATA[<p>hab da mal ne eigene Methode entwickelt für die GDI, damit das nich so flackert.<br />
hab dafür nen Doublebuffer verwendet.</p>
<p>guck dir einfach mal den Code an:</p>
<pre><code class="language-cpp">#if defined _M_IX86 
#pragma comment(linker,&quot;/manifestdependency:\&quot;type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\&quot;&quot;) 
#elif defined _M_IA64 
#pragma comment(linker,&quot;/manifestdependency:\&quot;type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\&quot;&quot;) 
#elif defined _M_X64 
#pragma comment(linker,&quot;/manifestdependency:\&quot;type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\&quot;&quot;) 
#else 
#pragma comment(linker,&quot;/manifestdependency:\&quot;type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\&quot;&quot;) 
#endif

#pragma comment(lib, &quot;comctl32.lib&quot;)

#pragma warning(disable: 4244)
#pragma warning(disable: 4311)
#pragma warning(disable: 4312)

#include &lt;windows.h&gt;
#include &lt;commctrl.h&gt;

#define IDC_BALL 500
#define IDT_BALL 501

typedef struct _ELLIPSE_DESC
{
	COORD cUpperLeft;
	COORD cLowerRight;
	int cx, cy;
} SEllipseDesc, *PEllipseDesc;

BOOL CALLBACK ChildEnumProc(HWND hWnd, LPARAM lParam)
{
	InvalidateRect(hWnd, NULL, TRUE);
	return TRUE;
}

HDC BeginScene(HWND hWnd, HBITMAP* pBitmap)
{
	RECT r = { 0 };
	GetClientRect(hWnd, &amp;r);
	r.right -= r.left;
	r.bottom -= r.top;
	HDC hWindowDC = GetDC(hWnd);
	HDC hDoubleBufferDC = CreateCompatibleDC(hWindowDC);
	*pBitmap = CreateCompatibleBitmap(hWindowDC, r.right, r.bottom);
	SelectObject(hDoubleBufferDC, (*pBitmap));
	ReleaseDC(hWnd, hWindowDC);
	wchar_t szClassName[1024];
	GetClassName(hWnd, szClassName, 1024);
	WNDCLASSEX wce = { 0 };
	GetClassInfoEx(GetModuleHandle(NULL), szClassName, &amp;wce);
	FillRect(hDoubleBufferDC, &amp;r, wce.hbrBackground);
	return hDoubleBufferDC;
}

void EndScene(HWND hWnd, HDC hDoubleBufferDC, HBITMAP hBitmap)
{
	RECT r = { 0 };
	GetUpdateRect(hWnd, &amp;r, FALSE);
	if ((r.bottom == 0) &amp;&amp; (r.left == 0) &amp;&amp; (r.right == 0) &amp;&amp; (r.top == 0))
		GetClientRect(hWnd, &amp;r);
	PAINTSTRUCT ps = { 0 };
	HDC hWindowDC = BeginPaint(hWnd, &amp;ps);
	StretchBlt(hWindowDC, r.left, r.top, r.right, r.bottom, hDoubleBufferDC, r.left, r.top, r.right, r.bottom, SRCCOPY);
	EndPaint(hWnd, &amp;ps);
	DeleteObject(hBitmap);
	DeleteDC(hDoubleBufferDC);
	ValidateRect(hWnd, &amp;r);
	EnumChildWindows(hWnd, ChildEnumProc, 0);
}

LRESULT CALLBACK ChildProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_CREATE:
		{
			PEllipseDesc pED = new SEllipseDesc;
			pED-&gt;cUpperLeft.X = 0;
			pED-&gt;cUpperLeft.Y = 0;
			pED-&gt;cLowerRight.X = 40;
			pED-&gt;cLowerRight.Y = 40;
			pED-&gt;cx = 1;
			pED-&gt;cy = 1;
			SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pED);
			SetTimer(hWnd, IDT_BALL, 1, NULL);
			return 0;
		} break;
	case WM_TIMER:
		{
			if (wParam == IDT_BALL)
			{
				PEllipseDesc pED = (PEllipseDesc)GetWindowLongPtr(hWnd, GWLP_USERDATA);
				pED-&gt;cUpperLeft.X += pED-&gt;cx;
				pED-&gt;cUpperLeft.Y += pED-&gt;cy;
				pED-&gt;cLowerRight.X += pED-&gt;cx;
				pED-&gt;cLowerRight.Y += pED-&gt;cy;
				if (pED-&gt;cUpperLeft.X &lt;= 0)
					pED-&gt;cx = 1;
				if (pED-&gt;cUpperLeft.Y &lt;= 0)
					pED-&gt;cy = 1;
				if (pED-&gt;cLowerRight.X &gt;= 774)
					pED-&gt;cx = -1;
				if (pED-&gt;cLowerRight.Y &gt;= 554)
					pED-&gt;cy = -1;
				InvalidateRect(hWnd, NULL, TRUE);
				return 0;
			}
		} break;
	case WM_PAINT:
		{
			HBITMAP hBmp = NULL;
			HDC hDC = BeginScene(hWnd, &amp;hBmp);
			PEllipseDesc pED = (PEllipseDesc)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, CreateSolidBrush(RGB(10, 120, 220)));
			Ellipse(hDC, pED-&gt;cUpperLeft.X, pED-&gt;cUpperLeft.Y, pED-&gt;cLowerRight.X, pED-&gt;cLowerRight.Y);
			DeleteObject(SelectObject(hDC, hOldBrush));
			EndScene(hWnd, hDC, hBmp);
			return 0;
		} break;
	case WM_ERASEBKGND:
		{
			return 1;
		} break;
	case WM_DESTROY:
		{
			KillTimer(hWnd, IDT_BALL);
			PEllipseDesc pED = (PEllipseDesc)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			delete pED;
			return 0;
		} break;
	}
	return DefWindowProc(hWnd, msg, wParam, lParam);
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_CREATE:
		{
			LPCREATESTRUCT pCS = (LPCREATESTRUCT)lParam;
			HWND hBallWnd = CreateWindowEx(0, L&quot;BALL_CHILD_24DC66A6_09DC_4001_A30D_2C3F050F04FE&quot;, L&quot;Ball&quot;, WS_CHILD|WS_BORDER|WS_VISIBLE, 10, 10, 774, 554, hWnd, (HMENU)IDC_BALL, pCS-&gt;hInstance, NULL);
			if (IsWindow(hBallWnd) == FALSE)
			{
				MessageBox(hWnd, L&quot;Fehler: Ball Fenster konnte nicht erstellt werden!&quot;, L&quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd);
				return 0;
			}
			ShowWindow(hBallWnd, SW_SHOW);
			UpdateWindow(hBallWnd);
			return 0;
		} break;
	case WM_PAINT:
		{
			HBITMAP hBmp = NULL;
			HDC hDC = BeginScene(hWnd, &amp;hBmp);
			EndScene(hWnd, hDC, hBmp);
			return 0;
		} break;
	case WM_CLOSE:
		{
			DestroyWindow(hWnd);
			return 0;
		} break;
	case WM_DESTROY:
		{
			PostQuitMessage(0);
			return 0;
		} break;
	case WM_ERASEBKGND:
		{
			return 1;
		} break;
	}
	return DefWindowProc(hWnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iShowCmd)
{
	InitCommonControls();
	WNDCLASSEX wce;
	wce.cbClsExtra = 0;
	wce.cbSize = sizeof(WNDCLASSEX);
	wce.cbWndExtra = 0;
	wce.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
	wce.hCursor = LoadCursor(NULL, IDC_ARROW);
	HICON hIcon = LoadIcon(NULL, IDI_WINLOGO);
	wce.hIcon = hIcon;
	wce.hIconSm = hIcon;
	wce.hInstance = hInstance;
	wce.lpfnWndProc = WndProc;
	wce.lpszClassName = L&quot;BALL_MAIN_D39C6525_0C87_486D_ABB3_35F15D359F91&quot;;
	wce.lpszMenuName = NULL;
	wce.style = CS_OWNDC|CS_DBLCLKS|CS_BYTEALIGNWINDOW|CS_BYTEALIGNCLIENT|CS_HREDRAW|CS_VREDRAW;
	RegisterClassEx(&amp;wce);
	wce.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wce.lpszClassName = L&quot;BALL_CHILD_24DC66A6_09DC_4001_A30D_2C3F050F04FE&quot;;
	wce.cbClsExtra = sizeof(PEllipseDesc);
	wce.cbWndExtra = sizeof(PEllipseDesc);
	wce.lpfnWndProc = ChildProc;
	RegisterClassEx(&amp;wce);
	HWND hMainWindow = CreateWindowEx(0, L&quot;BALL_MAIN_D39C6525_0C87_486D_ABB3_35F15D359F91&quot;, L&quot;Ball Version 1.0&quot;, WS_OVERLAPPED|WS_POPUP|WS_SYSMENU|WS_CAPTION|WS_MINIMIZEBOX|WS_VISIBLE, (GetSystemMetrics(SM_CXSCREEN) - 800) / 2, (GetSystemMetrics(SM_CYSCREEN) - 600) / 2, 800, 600, GetDesktopWindow(), NULL, hInstance, NULL);
	if (IsWindow(hMainWindow) == FALSE)
	{
		MessageBox(GetDesktopWindow(), L&quot;Fehler: Hauptfenster konnte nicht erstellt werden!&quot;, L&quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
		return 0;
	}
	ShowWindow(hMainWindow, SW_SHOW);
	UpdateWindow(hMainWindow);
	MSG msg;
	while (GetMessage(&amp;msg, NULL, 0, 0))
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}
	return (int)(msg.wParam);
}
</code></pre>
<p>der Ball springt absolut Flackerfrei...<br />
dank dem Doublebuffer.</p>
<p>nochmal die Teile, auf die es ankommt:</p>
<pre><code class="language-cpp">BOOL CALLBACK ChildEnumProc(HWND hWnd, LPARAM lParam)
{
	InvalidateRect(hWnd, NULL, TRUE);
	return TRUE;
}

HDC BeginScene(HWND hWnd, HBITMAP* pBitmap)
{
	RECT r = { 0 };
	GetClientRect(hWnd, &amp;r);
	r.right -= r.left;
	r.bottom -= r.top;
	HDC hWindowDC = GetDC(hWnd);
	HDC hDoubleBufferDC = CreateCompatibleDC(hWindowDC);
	*pBitmap = CreateCompatibleBitmap(hWindowDC, r.right, r.bottom);
	SelectObject(hDoubleBufferDC, (*pBitmap));
	ReleaseDC(hWnd, hWindowDC);
	wchar_t szClassName[1024];
	GetClassName(hWnd, szClassName, 1024);
	WNDCLASSEX wce = { 0 };
	GetClassInfoEx(GetModuleHandle(NULL), szClassName, &amp;wce);
	FillRect(hDoubleBufferDC, &amp;r, wce.hbrBackground);
	return hDoubleBufferDC;
}

void EndScene(HWND hWnd, HDC hDoubleBufferDC, HBITMAP hBitmap)
{
	RECT r = { 0 };
	GetUpdateRect(hWnd, &amp;r, FALSE);
	if ((r.bottom == 0) &amp;&amp; (r.left == 0) &amp;&amp; (r.right == 0) &amp;&amp; (r.top == 0))
		GetClientRect(hWnd, &amp;r);
	PAINTSTRUCT ps = { 0 };
	HDC hWindowDC = BeginPaint(hWnd, &amp;ps);
	StretchBlt(hWindowDC, r.left, r.top, r.right, r.bottom, hDoubleBufferDC, r.left, r.top, r.right, r.bottom, SRCCOPY);
	EndPaint(hWnd, &amp;ps);
	DeleteObject(hBitmap);
	DeleteDC(hDoubleBufferDC);
	ValidateRect(hWnd, &amp;r);
	EnumChildWindows(hWnd, ChildEnumProc, 0);
}
</code></pre>
<p>die Funktionen kannst du direkt übernehmen und an Stelle von BeginPaint und EndPaint einsetzen.<br />
die ChildEnumProc ist ganz wichtig, da ohne sie die EndScene() nicht funzt xD<br />
wenn du nur ein Fenster hast geht es auch, in dem du die Zeil in EndScene löschst (EnumChildWindow(...)),<br />
aber sobald dein Fenster ein Child hast, musst du die Funktion haben, da sonst die Child Fentser nicht<br />
neugezeichnet werden und das unschöne Effekte mit sich bringt.</p>
<p>dann is noch wichtig:</p>
<pre><code class="language-cpp">case WM_ERASEBKGND:
    {
	return 1;
    } break;
</code></pre>
<p>damit wird der Hintergrund nicht immer gelöscht -&gt; flackern fällt flach <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>und verwendet wird das ganze in der WM_PAINT:</p>
<pre><code class="language-cpp">case WM_PAINT:
		{
			HBITMAP hBmp = NULL;
			HDC hDC = BeginScene(hWnd, &amp;hBmp);
			// ... hier kann mit in den hDC gezeichnet werden
			EndScene(hWnd, hDC, hBmp);
			return 0;
		} break;
</code></pre>
<p>hoffe das war eingermaßen verständlich <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>MfG DrakoXP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1343122</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1343122</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sun, 12 Aug 2007 12:10:30 GMT</pubDate></item><item><title><![CDATA[Reply to Flackern bei Fenster neu Zeichnen on Sun, 12 Aug 2007 22:30:42 GMT]]></title><description><![CDATA[<p>Es gibt zahlreiche Möglichkeiten, ein Flackern zu verhindern... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> google, Forumsuche!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1343402</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1343402</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 12 Aug 2007 22:30:42 GMT</pubDate></item><item><title><![CDATA[Reply to Flackern bei Fenster neu Zeichnen on Mon, 13 Aug 2007 15:15:52 GMT]]></title><description><![CDATA[<p>Meine find ich am schönsten <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1343785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1343785</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Mon, 13 Aug 2007 15:15:52 GMT</pubDate></item></channel></rss>