<?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[Problem mit SubClassing]]></title><description><![CDATA[<p>hallo Leutz,</p>
<p>ich habe folgendes Problem:<br />
In einer Anwendung habe ich eine CommonControl gesubclasset mit<br />
SetWindowLong(GWL_WNDPROC), ...);<br />
das funktioniert auch alles fein.</p>
<p>Jetzt habe ich das XP-Manifest dazugetan und schon geht es nicht mehr.<br />
Das Programm stürzt einfach ab.</p>
<p>Kann das eventuell daran liegen, dass die Common Controls aus der comctl32.dll Unicode sind und meine Anwendung ANSI is?</p>
<p>thx im voraus</p>
<p>MfG DrakoXP</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/188562/problem-mit-subclassing</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 14:39:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/188562.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Aug 2007 18:11:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit SubClassing on Wed, 01 Aug 2007 18:11:10 GMT]]></title><description><![CDATA[<p>hallo Leutz,</p>
<p>ich habe folgendes Problem:<br />
In einer Anwendung habe ich eine CommonControl gesubclasset mit<br />
SetWindowLong(GWL_WNDPROC), ...);<br />
das funktioniert auch alles fein.</p>
<p>Jetzt habe ich das XP-Manifest dazugetan und schon geht es nicht mehr.<br />
Das Programm stürzt einfach ab.</p>
<p>Kann das eventuell daran liegen, dass die Common Controls aus der comctl32.dll Unicode sind und meine Anwendung ANSI is?</p>
<p>thx im voraus</p>
<p>MfG DrakoXP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1336771</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1336771</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Wed, 01 Aug 2007 18:11:10 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Wed, 01 Aug 2007 22:26:11 GMT]]></title><description><![CDATA[<p>Welche IDE Beutzt du <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="😕"
    /> wie hast du das XP Style eingebunden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1336939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1336939</guid><dc:creator><![CDATA[Ascharan]]></dc:creator><pubDate>Wed, 01 Aug 2007 22:26:11 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Thu, 02 Aug 2007 14:50:54 GMT]]></title><description><![CDATA[<p>ich benutze Visual C++ 6 (1998)</p>
<p>und habe das XP-Theme über das XP-Manifest eingebunden.<br />
Aber das passt alles, wenn ich nichts subclasse funktioniert ja auch alles MIT XP!</p>
<p>bloß SubClassing UND XP vertragen sich bei mir i.w. net <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/1337410</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1337410</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Thu, 02 Aug 2007 14:50:54 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Fri, 03 Aug 2007 08:53:36 GMT]]></title><description><![CDATA[<p>DrakoXP schrieb:</p>
<blockquote>
<p>Kann das eventuell daran liegen, dass die Common Controls aus der comctl32.dll Unicode sind und meine Anwendung ANSI is?...</p>
</blockquote>
<p>Nö</p>
<p>Andere frage wie stürzt es ab.<br />
1. Startet nicht<br />
2. Error Message</p>
<p>und Was sagt der debugger</p>
<p>ist InitCommonControls(); geladen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1337904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1337904</guid><dc:creator><![CDATA[Ascharan]]></dc:creator><pubDate>Fri, 03 Aug 2007 08:53:36 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Fri, 03 Aug 2007 16:13:10 GMT]]></title><description><![CDATA[<p>wie gesagt: ohne Subclassing gehts, also erübrigt sich die Frage nach InitCommonControls().</p>
<p>das Programm meldet direkt, wenn man es startet:<br />
&quot;[Programmname] hat ein Problem festgestellt und muss beendet werden.&quot;</p>
<p>mir ist außerdem aufgefallen, dass dieses Problem nur in der Release-Version auftritt.<br />
in der Debug-Version funktioniert es</p>
<p>und da der Fehler nur in der Release-Version auftritt, sagt der Debugger gar nix dazu <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/1338308</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338308</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Fri, 03 Aug 2007 16:13:10 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Fri, 03 Aug 2007 20:43:14 GMT]]></title><description><![CDATA[<p>Hast Du die CommonControls richtig initlialisiert (siehe Ascharan's Frage!) ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338421</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338421</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Fri, 03 Aug 2007 20:43:14 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Fri, 03 Aug 2007 21:48:24 GMT]]></title><description><![CDATA[<p>am besten du zeigst mal n bissle code <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/1338448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338448</guid><dc:creator><![CDATA[Ascharan]]></dc:creator><pubDate>Fri, 03 Aug 2007 21:48:24 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Fri, 03 Aug 2007 22:13:58 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12048">@CodeFinder</a>: JA!!!!!!!! (sry, dass ich leicht gereizt reagiere^^)</p>
<p>und hier der gewünschte Code...</p>
<p>main.cpp</p>
<pre><code>// Windows Application Programming Interface
#include &lt;windows.h&gt;

// Windows Common Controls
#include &lt;commctrl.h&gt;

// C Standard Library
#include &lt;cstdlib&gt;

// C Time
#include &lt;ctime&gt;

// C Mathematics
#include &lt;cmath&gt;

// C Standard Input Output
#include &lt;cstdio&gt;

// Resource IDs
#include &quot;resource.h&quot;

// Controls
HWND g_hStaticCount = NULL;
HWND g_hEditCount = NULL;
HWND g_hButtonDrop = NULL;
HWND g_hRenderDrops = NULL;
HWND g_hStaticPI = NULL;
HWND g_hEditPI = NULL;
HWND g_hProgressPI = NULL;

// Handle des Threads
HANDLE hPIThread = INVALID_HANDLE_VALUE;

// Die Tropfen
int g_iNumDrops = 0;
LPPOINT g_pDrops = NULL;

// Button Subclassen
WNDPROC pOldButtonProc = NULL;
LRESULT CALLBACK SubButtonProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {
	case WM_KEYDOWN:
		{
			switch (wParam) {
			case VK_RETURN:
				{
					SendMessage(GetParent(hWnd), WM_COMMAND, IDC_DROP, 0);
				} break;
			case VK_TAB:
				{
					SetFocus(g_hEditCount);
				} break;
			default:
				return pOldButtonProc(hWnd, msg, wParam, lParam);
			}
			return 0;
		} break;
	}
	return pOldButtonProc(hWnd, msg, wParam, lParam);
}

// Edit Subclassen
WNDPROC pOldEditProc = NULL;
LRESULT CALLBACK SubEditProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {
	case WM_KEYDOWN:
		{
			switch (wParam) {
			case VK_RETURN:
				{
					SendMessage(GetParent(hWnd), WM_COMMAND, IDC_DROP, 0);
				} break;
			case VK_TAB:
				{
					SetFocus(g_hButtonDrop);
				} break;
			default:
				return pOldEditProc(hWnd, msg, wParam, lParam);
			}
			return 0;
		} break;
	}
	return pOldEditProc(hWnd, msg, wParam, lParam);
}

// PI berechnen!!!
DWORD WINAPI PIThread(LPVOID pParam) {
	InvalidateRect(g_hRenderDrops, NULL, TRUE);
	Sleep(100);
	HWND hWnd = (HWND)pParam;
	srand(time(NULL));
	ShowWindow(g_hProgressPI, SW_SHOW);
	SendMessage(g_hProgressPI, PBM_SETPOS, 0, 0);
	char szBuffer[1024];
	GetWindowText(g_hEditCount, szBuffer, 1024);
	g_iNumDrops = atoi(szBuffer);
	if (g_pDrops) {
		delete[] g_pDrops;
		g_pDrops = NULL;
	}
	g_pDrops = new POINT[g_iNumDrops];
	int iInCircle = 0, iComplete = 0;
	RECT r;
	GetClientRect(g_hRenderDrops, &amp;r);
	int x0 = (r.right - r.left) / 2;
	int y0 = (r.bottom - r.top) / 2;
	HDC hDC = GetDC(g_hRenderDrops);
	for (int n = 0; n &lt; g_iNumDrops; n++) {
		g_pDrops[n].x = (rand() % 301) - 151;
		g_pDrops[n].y = (rand() % 301) - 151;
		double way = sqrt(pow((double)(g_pDrops[n].x), 2) + pow((double)(g_pDrops[n].y), 2));
		if (way &lt;= 150.0f) {
			HPEN hBluePen = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
			HPEN hOldPen = (HPEN)SelectObject(hDC, hBluePen);
			HBRUSH hBlueBrush = (HBRUSH)CreateSolidBrush(RGB(0, 0, 255));
			HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBlueBrush);
			Ellipse(hDC, x0 + g_pDrops[n].x - 2, y0 - g_pDrops[n].y + 2, x0 + g_pDrops[n].x + 2, y0 - g_pDrops[n].y - 2);
			DeleteObject(hOldPen);
			DeleteObject(hOldBrush);
			iInCircle++;
		} else {
			HPEN hBlackPen = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
			HPEN hOldPen = (HPEN)SelectObject(hDC, hBlackPen);
			HBRUSH hBlackBrush = (HBRUSH)CreateSolidBrush(RGB(0, 0, 0));
			HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBlackBrush);
			Ellipse(hDC, x0 + g_pDrops[n].x - 2, y0 - g_pDrops[n].y + 2, x0 + g_pDrops[n].x + 2, y0 - g_pDrops[n].y - 2);
			DeleteObject(hOldPen);
			DeleteObject(hOldBrush);
		}
		iComplete++;
		SendMessage(g_hProgressPI, PBM_SETPOS, (WPARAM)((100.0f / (double)g_iNumDrops) * (double)n), 0);
	}
	ReleaseDC(g_hRenderDrops, hDC);
	double pi = 4.0f * (double)iInCircle / (double)iComplete;
	sprintf(szBuffer, &quot;%f&quot;, pi);
	SetWindowText(g_hEditPI, szBuffer);
	SendMessage(g_hProgressPI, PBM_SETPOS, 100, 0);
	ShowWindow(g_hProgressPI, SW_HIDE);
	return 0;
}

// Render Window Procedure
LRESULT CALLBACK RenderProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {
	case WM_PAINT: // Zeichnen
		{
			PAINTSTRUCT ps;
			HDC hDC = BeginPaint(hWnd, &amp;ps); // Zeichnen - Anfang
			{
				RECT r;
				GetClientRect(hWnd, &amp;r);
				int x0 = (r.right - r.left) / 2;
				int y0 = (r.bottom - r.top) / 2;
				HPEN hRectPen = CreatePen(PS_SOLID, 1, RGB(0, 255, 0));
				HPEN hOldPen = (HPEN)SelectObject(hDC, hRectPen);
				// Das Quadrat zeichnen
				Rectangle(hDC, x0 - 150, y0 - 150, x0 + 150, y0 + 150);
				DeleteObject(hOldPen);
				HPEN hCirclePen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
				hOldPen = (HPEN)SelectObject(hDC, hCirclePen);
				// Den Kreis zeichnen
				Ellipse(hDC, x0 - 150, y0 - 150, x0 + 150, y0 + 150);
				DeleteObject(hOldPen);
				// Die Tropfen zeichnen
				if (g_pDrops) {
					if (g_iNumDrops) {
						for (int n = 0; n &lt; g_iNumDrops; n++) {
							if ((g_pDrops[n].x &lt;= 150) &amp;&amp; (g_pDrops[n].y &lt;= 150) &amp;&amp; (g_pDrops[n].x &gt;= -150) &amp;&amp; (g_pDrops[n].y &gt;= -150)) {
								double way = sqrt(pow((double)(g_pDrops[n].x), 2) + pow((double)(g_pDrops[n].y), 2));
								if (way &lt;= 150.0f) {
									HPEN hBluePen = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
									HPEN hOldPen = (HPEN)SelectObject(hDC, hBluePen);
									HBRUSH hBlueBrush = (HBRUSH)CreateSolidBrush(RGB(0, 0, 255));
									HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBlueBrush);
									Ellipse(hDC, x0 + g_pDrops[n].x - 2, y0 - g_pDrops[n].y + 2, x0 + g_pDrops[n].x + 2, y0 - g_pDrops[n].y - 2);
									DeleteObject(hOldPen);
									DeleteObject(hOldBrush);
								} else {
									HPEN hBlackPen = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
									HPEN hOldPen = (HPEN)SelectObject(hDC, hBlackPen);
									HBRUSH hBlackBrush = (HBRUSH)CreateSolidBrush(RGB(0, 0, 0));
									HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBlackBrush);
									Ellipse(hDC, x0 + g_pDrops[n].x - 2, y0 - g_pDrops[n].y + 2, x0 + g_pDrops[n].x + 2, y0 - g_pDrops[n].y - 2);
									DeleteObject(hOldPen);
									DeleteObject(hOldBrush);
								}
							}
						}
					}
				}
			}
			EndPaint(hWnd, &amp;ps); // Zeichnen - Ende
			return 0;
		} break;
	}
	return DefWindowProc(hWnd, msg, wParam, lParam);
}

// Main Window Procedure
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {
	case WM_KEYDOWN:
		{
			switch (wParam) {
			case VK_RETURN:
				{
					SendMessage(hWnd, WM_COMMAND, IDC_DROP, 0);
				} break;
			case VK_TAB:
				{
					SetFocus(g_hEditCount);
				} break;
			}
			return 0;
		} break;
	case WM_CREATE: // Wenn Fenster erstellt wird
		{
			LPCREATESTRUCT pCS = (LPCREATESTRUCT)lParam;
			// Statischen Text für Anzahl der Tropfen erstellen
			g_hStaticCount = CreateWindow(&quot;STATIC&quot;, &quot;Anzahl Tropfen:&quot;, WS_VISIBLE|WS_CHILD|SS_SIMPLE, 10, 10, 108, 20, hWnd, (HMENU)IDC_STATIC_COUNT, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hStaticCount) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			// Editbox für Anzahl der Tropfen erstellen
			g_hEditCount = CreateWindow(&quot;EDIT&quot;, &quot;256&quot;, WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|WS_GROUP, 128, 10, 546, 20, hWnd, (HMENU)IDC_COUNT, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hEditCount) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			pOldEditProc = (WNDPROC)SetWindowLong(g_hEditCount, GWL_WNDPROC, (LONG)SubEditProc);
			// Button zum Starten erstellen
			g_hButtonDrop = CreateWindow(&quot;BUTTON&quot;, &quot;Start&quot;, WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON|WS_TABSTOP, 684, 10, 100, 20, hWnd, (HMENU)IDC_DROP, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hButtonDrop) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			pOldButtonProc = (WNDPROC)SetWindowLong(g_hButtonDrop, GWL_WNDPROC, (LONG)SubButtonProc);
			// Renderwindow zum Zeichnen erstellen
			g_hRenderDrops = CreateWindow(&quot;PIRenderWindow&quot;, &quot;&quot;, WS_VISIBLE|WS_CHILD|WS_BORDER, 10, 40, 774, 474, hWnd, (HMENU)IDC_RENDER, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hRenderDrops) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			// Statischen Text für PI erstellen
			g_hStaticPI = CreateWindow(&quot;STATIC&quot;, &quot;PI:&quot;, WS_VISIBLE|WS_CHILD|SS_SIMPLE, 10, 524, 20, 20, hWnd, (HMENU)IDC_STATIC_PI, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hStaticPI) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			// Edit Box für PI erstellen
			g_hEditPI = CreateWindow(&quot;EDIT&quot;, &quot;3.141592654&quot;, WS_VISIBLE|WS_CHILD|WS_BORDER, 40, 524, 120, 20, hWnd, (HMENU)IDC_PI, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hEditPI) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			EnableWindow(g_hEditPI, FALSE); // Fenster deaktivieren
			// Fortschrittsanzeige erstellen
			g_hProgressPI = CreateWindowEx(0, PROGRESS_CLASS, &quot;&quot;, WS_VISIBLE|WS_CHILD|PBS_SMOOTH , 170, 524, 612, 20, hWnd, (HMENU)IDC_PROGRESS, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hProgressPI) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			ShowWindow(g_hProgressPI, SW_HIDE);
			SendMessage(g_hProgressPI, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
			SendMessage(g_hProgressPI, PBM_SETPOS, 0, 0);
			return 0;
		} break;
	case WM_CLOSE: // Wenn Fenster geschlossen wird
		{
			DestroyWindow(hWnd); // Fenster zerstören
			return 0;
		} break;
	case WM_DESTROY: // Wenn Fenster zerstört wird
		{
			if (hPIThread != INVALID_HANDLE_VALUE) {
				ShowWindow(g_hProgressPI, SW_HIDE);
				TerminateThread(hPIThread, 0);
				if (g_iNumDrops) g_iNumDrops = 0;
				if (g_pDrops) { delete[] g_pDrops; g_pDrops = NULL; }
			}
			PostQuitMessage(0); // Programm beenden
			return 0;
		} break;
	case WM_SYSCOMMAND: // Wenn ein Systembefehl gesendet wird
		{
			switch (wParam) {
			case ID_SYSMENU_INFO: // Wenn auf Über &quot;PI Rechner&quot; geklickt wurde
				{
					// Copyright-Info anzeigen
					MessageBox(hWnd, &quot;PI Rechner Version 1.0\nCopyright (C) 2007, PI-Mania Projekt Christoph Graupner Gymnasium Kirchberg\n\nProgrammiert von Felix Bytow.\nIcon von Christian Meier.&quot;, &quot;Über \&quot;PI Rechner\&quot;&quot;, MB_OK|MB_ICONINFORMATION);
				} break;
			default:
				// Standard Window Prozedur ausführen
				return DefWindowProc(hWnd, msg, wParam, lParam);
			}
			return 0;
		} break;
	case WM_COMMAND: // Wenn ein Befehl gesendet wird
		{
			switch (wParam) {
			case IDC_DROP: // Wenn auf [Start] geklickt wird
				{
					if (hPIThread != INVALID_HANDLE_VALUE) {
						ShowWindow(g_hProgressPI, SW_HIDE);
						TerminateThread(hPIThread, 0);
						if (g_iNumDrops) g_iNumDrops = 0;
						if (g_pDrops) { delete[] g_pDrops; g_pDrops = NULL; }
					}
					DWORD dwDisposition;
					hPIThread = CreateThread(NULL, 0, PIThread, (LPVOID)hWnd, 0, &amp;dwDisposition);
					if (hPIThread == INVALID_HANDLE_VALUE) {
						MessageBox(hWnd, &quot;Fehler: Der Thread zur Berechnung von PI konnte nicht gestartet werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
					}
				} break;
			case ID_MENUE_INFO: // Wenn auf [Info]-&gt;[Über das Programm...] geklickt wird
				{
					// Copyright-Info anzeigen
					MessageBox(hWnd, &quot;PI Rechner Version 1.0\nCopyright (C) 2007, PI-Mania Projekt Christoph Graupner Gymnasium Kirchberg\n\nProgrammiert von Felix Bytow.\nIcon von Christian Meier.&quot;, &quot;Über \&quot;PI Rechner\&quot;&quot;, MB_OK|MB_ICONINFORMATION);
				} break;
			case ID_MENUE_EXIT: // Wenn auf [Datei]-&gt;[Beenden] geklickt wird
				{
					// Beenden
					DestroyWindow(hWnd);
				} break;
			case ID_MENUE_DESCRIPTION:
				{
					// Erklärung anzeigen
					ShellExecute(hWnd, &quot;open&quot;, &quot;http://de.wikipedia.org/wiki/Kreiszahl#Statistische_Bestimmung&quot;, 0, 0, SW_SHOWMAXIMIZED);
				} break;
			}
			return 0;
		} break;
	case WM_GETMINMAXINFO:
		{
			MINMAXINFO* pMinMaxInfo = (MINMAXINFO*)lParam;
			pMinMaxInfo-&gt;ptMinTrackSize.y = 447;
			pMinMaxInfo-&gt;ptMinTrackSize.x = 361;
			return 0;
		} break;
	case WM_SIZE:
		{
			RECT r;
			GetClientRect(hWnd, &amp;r);
			r.right -= r.left;
			r.bottom -= r.top;
			r.left = 0;
			r.top = 0;
			MoveWindow(g_hStaticCount, 10, 10, 108, 20, TRUE);
			MoveWindow(g_hButtonDrop, r.right - 110, 10, 100, 20, TRUE);
			MoveWindow(g_hEditCount, 128, 10, r.right - 248, 20, TRUE);
			MoveWindow(g_hRenderDrops, 10, 40, r.right - 20, r.bottom - 80, TRUE);
			MoveWindow(g_hStaticPI, 10, r.bottom - 30, 20, 20, TRUE);
			MoveWindow(g_hEditPI, 40, r.bottom - 30, 120, 20, TRUE);
			MoveWindow(g_hProgressPI, 170, r.bottom - 30, r.right - 180, 20, TRUE);
			return 0;
		} break;
	}
	// Standard Window Prozedur ausführen
	return DefWindowProc(hWnd, msg, wParam, lParam);
}

// Hauptprogramm
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) {
	InitCommonControls(); // Steuerelemente initialisieren
	WNDCLASS wc; // Die Hauptfensterklasse
	wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hInstance = hInstance;
	wc.lpszMenuName = MAKEINTRESOURCE(ID_MAINMENU);
	wc.lpszClassName = &quot;PIMainWindow&quot;;
	wc.lpfnWndProc = WndProc;
	wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.style = CS_HREDRAW|CS_VREDRAW;
	RegisterClass(&amp;wc); // Fensterklasse registrieren
	wc.lpszClassName = &quot;PIRenderWindow&quot;;
	wc.lpfnWndProc = RenderProc;
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.hIcon = NULL;
	wc.hCursor = LoadCursor(NULL, IDC_CROSS);
	RegisterClass(&amp;wc); // Fensterklasse registrieren für Render-Window
	// Fenster erstellen
	HWND hWnd = CreateWindow(&quot;PIMainWindow&quot;, &quot;PI Rechner von Felix Bytow&quot;, WS_OVERLAPPEDWINDOW, (GetSystemMetrics(SM_CXSCREEN) - 800) / 2, (GetSystemMetrics(SM_CYSCREEN) - 600) / 2, 800, 600, GetDesktopWindow(), NULL, hInstance, NULL);
	if (IsWindow(hWnd) == FALSE) { // Konnte das Fenster erstellt werden?
		// Nein? -&gt; Fehler ausgeben!
		MessageBox(GetDesktopWindow(), &quot;Fehler: Hauptfenster konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
		return 0;
	}
	// Systemmenü modifizieren
	HMENU hSysMenu = GetSystemMenu(hWnd, FALSE);
	AppendMenu(hSysMenu, MF_SEPARATOR, 0, NULL);
	AppendMenu(hSysMenu, MF_STRING, ID_SYSMENU_INFO, &quot;Über \&quot;PI Rechner\&quot;&quot;);
	// Hauptfenster anzeigen
	ShowWindow(hWnd, iCmdShow);
	// Hauptfenster updaten
	UpdateWindow(hWnd);
	// Nachrichtenschleife
	MSG msg;
	while (GetMessage(&amp;msg, NULL, 0, 0)) { // Wiederhole bis PostQuitMessage aufgerufen wird
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}
	return msg.wParam; // Programmende
}
</code></pre>
<p>resource.h:</p>
<pre><code class="language-cpp">#ifndef RESOURCE_H
#define RESOURCE_H

// Symbol
#define IDI_APPICON 100

// Programmmenü
#define ID_MAINMENU 500
#define ID_MENUE_EXIT 501
#define ID_MENUE_INFO 502
#define ID_MENUE_DESCRIPTION 503

// Systemmenü
#define ID_SYSMENU_INFO 600

// Fenster und Controls
#define IDC_COUNT 800
#define IDC_DROP 801
#define IDC_STATIC_COUNT 802
#define IDC_RENDER 803
#define IDC_STATIC_PI 804
#define IDC_PI 805
#define IDC_PROGRESS 806

#endif
</code></pre>
<p>pi.rc:</p>
<pre><code class="language-cpp">//Microsoft Developer Studio generated resource script.
//
#include &quot;resrc1.h&quot;

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include &quot;windows.h&quot;
#undef APSTUDIO_HIDDEN_SYMBOLS
#include &quot;resource.h&quot;

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// Deutsch (Deutschland) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
#ifdef _WIN32
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APPICON             ICON    DISCARDABLE     &quot;PI Rechner.ico&quot;

/////////////////////////////////////////////////////////////////////////////
//
// Menu
//

ID_MAINMENU MENU DISCARDABLE 
BEGIN
    POPUP &quot;&amp;Datei&quot;
    BEGIN
        MENUITEM &quot;Be&amp;enden&quot;,                    ID_MENUE_EXIT
    END
    POPUP &quot;&amp;Info&quot;
    BEGIN
        MENUITEM &quot;Über das Programm...&quot;,        ID_MENUE_INFO
        MENUITEM &quot;Er&amp;klärung&quot;,                  ID_MENUE_DESCRIPTION
    END
END

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE 
BEGIN
    &quot;resrc1.h\0&quot;
END

2 TEXTINCLUDE DISCARDABLE 
BEGIN
    &quot;#define APSTUDIO_HIDDEN_SYMBOLS\r\n&quot;
    &quot;#include &quot;&quot;windows.h&quot;&quot;\r\n&quot;
    &quot;#undef APSTUDIO_HIDDEN_SYMBOLS\r\n&quot;
    &quot;#include &quot;&quot;resource.h&quot;&quot;\r\n&quot;
    &quot;\0&quot;
END

3 TEXTINCLUDE DISCARDABLE 
BEGIN
    &quot;\r\n&quot;
    &quot;\0&quot;
END

#endif    // APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////
//
// 24
//

1                       24      DISCARDABLE     &quot;PI Rechner.exe.Manifest&quot;
#endif    // Deutsch (Deutschland) resources
/////////////////////////////////////////////////////////////////////////////

#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED
</code></pre>
<p>und zu guter letzt das Manifest:</p>
<pre><code class="language-html">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
&lt;assembly
  xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;
  manifestVersion=&quot;1.0&quot;&gt;
&lt;assemblyIdentity
    name=&quot;DevCpp.Apps.PI_Rechner&quot;
    processorArchitecture=&quot;x86&quot;
    version=&quot;1.0.0.0&quot;
    type=&quot;win32&quot;/&gt;
&lt;description&gt;PI Rechner&lt;/description&gt;
&lt;dependency&gt;
    &lt;dependentAssembly&gt;
        &lt;assemblyIdentity
            type=&quot;win32&quot;
            name=&quot;Microsoft.Windows.Common-Controls&quot;
            version=&quot;6.0.0.0&quot;
            processorArchitecture=&quot;x86&quot;
            publicKeyToken=&quot;6595b64144ccf1df&quot;
            language=&quot;*&quot;
        /&gt;
    &lt;/dependentAssembly&gt;
&lt;/dependency&gt;
&lt;/assembly&gt;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1338457</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338457</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Fri, 03 Aug 2007 22:13:58 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Fri, 03 Aug 2007 22:13:16 GMT]]></title><description><![CDATA[<p>is zu viel xD^^</p>
<p>naja, also mal die Stellen, die mir relevant scheinen</p>
<p>Die ganzen Handles für die Steuerelemente</p>
<pre><code class="language-cpp">// Controls
HWND g_hStaticCount = NULL;
HWND g_hEditCount = NULL;
HWND g_hButtonDrop = NULL;
HWND g_hRenderDrops = NULL;
HWND g_hStaticPI = NULL;
HWND g_hEditPI = NULL;
HWND g_hProgressPI = NULL;
</code></pre>
<p>die gesubclassden WndProcs</p>
<pre><code class="language-cpp">// Button Subclassen
WNDPROC pOldButtonProc = NULL;
LRESULT CALLBACK SubButtonProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {
	case WM_KEYDOWN:
		{
			switch (wParam) {
			case VK_RETURN:
				{
					SendMessage(GetParent(hWnd), WM_COMMAND, IDC_DROP, 0);
				} break;
			case VK_TAB:
				{
					SetFocus(g_hEditCount);
				} break;
			default:
				return pOldButtonProc(hWnd, msg, wParam, lParam);
			}
			return 0;
		} break;
	}
	return pOldButtonProc(hWnd, msg, wParam, lParam);
}

// Edit Subclassen
WNDPROC pOldEditProc = NULL;
LRESULT CALLBACK SubEditProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {
	case WM_KEYDOWN:
		{
			switch (wParam) {
			case VK_RETURN:
				{
					SendMessage(GetParent(hWnd), WM_COMMAND, IDC_DROP, 0);
				} break;
			case VK_TAB:
				{
					SetFocus(g_hButtonDrop);
				} break;
			default:
				return pOldEditProc(hWnd, msg, wParam, lParam);
			}
			return 0;
		} break;
	}
	return pOldEditProc(hWnd, msg, wParam, lParam);
}
</code></pre>
<p>Der Teil mit SetWindowLong</p>
<pre><code class="language-cpp">// Editbox für Anzahl der Tropfen erstellen
			g_hEditCount = CreateWindow(&quot;EDIT&quot;, &quot;256&quot;, WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|WS_GROUP, 128, 10, 546, 20, hWnd, (HMENU)IDC_COUNT, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hEditCount) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			pOldEditProc = (WNDPROC)SetWindowLong(g_hEditCount, GWL_WNDPROC, (LONG)SubEditProc);
			// Button zum Starten erstellen
			g_hButtonDrop = CreateWindow(&quot;BUTTON&quot;, &quot;Start&quot;, WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON|WS_TABSTOP, 684, 10, 100, 20, hWnd, (HMENU)IDC_DROP, pCS-&gt;hInstance, NULL);
			if (IsWindow(g_hButtonDrop) == FALSE) { // Hat es geklappt?
				// Nein? -&gt; Fehler anzeigen!
				MessageBox(hWnd, &quot;Fehler: Ein Steuerelement konnte nicht erstellt werden!&quot;, &quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
				DestroyWindow(hWnd); // Fenster zerstören
				return 0;
			}
			pOldButtonProc = (WNDPROC)SetWindowLong(g_hButtonDrop, GWL_WNDPROC, (LONG)SubButtonProc);
</code></pre>
<p>noch was:<br />
der Fehler kommt jetzt auch bei der Debug Version ???...<br />
naja, hab mal im Debugger geguckt und aus irgend einem Grund ist in pOldButtonProc eine ungültige Adresse...</p>
<p>es gibt aber nur 2 schreibende Zugriffe im Code, die Initialisierung mit NULL und dann über SetWindowLong.<br />
Demnach gibt die einen falschen Wert zurück, nur warum?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338461</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338461</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Fri, 03 Aug 2007 22:13:16 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Fri, 03 Aug 2007 22:32:09 GMT]]></title><description><![CDATA[<p>Als erstes würd ich die globalen Variablen mal alle am Anfang des Programms setzen. Das ist ja grauenhaft das zwischen den Funktionen im Code Variablen 'gesetzt' werden.</p>
<p>Weiterhin wird die DefWindowProc für ein subgeclasstes Fenster nicht so aufrufen:</p>
<pre><code class="language-cpp">return pOldButtonProc(hWnd, msg, wParam, lParam);
</code></pre>
<p>sondern</p>
<pre><code class="language-cpp">return CallWindowProc(pOldButtonProc, hWnd, msg, wParam, lParam);
</code></pre>
<p>siehe <a href="http://msdn2.microsoft.com/en-us/library/ms633571.aspx" rel="nofollow">CallWindowProc</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338469</guid><dc:creator><![CDATA[Analog Bit]]></dc:creator><pubDate>Fri, 03 Aug 2007 22:32:09 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Sat, 04 Aug 2007 13:33:15 GMT]]></title><description><![CDATA[<p>gut, also abgesehen davon, dass das mit den Variablen nich sehr schick ist, liegt da kein Fehler, da es ohne XP-Themes funktioniert ;-).</p>
<p>ich werde mal CallWindowProc testen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1338664</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338664</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sat, 04 Aug 2007 13:33:15 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit SubClassing on Sat, 04 Aug 2007 13:34:13 GMT]]></title><description><![CDATA[<p>also thx, für den Tipp, jetzt klappts einwandfrei <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1338665</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1338665</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sat, 04 Aug 2007 13:34:13 GMT</pubDate></item></channel></rss>