<?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[Wie kann ich Callback-Funktion in einer Klasse bekannt machen?]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>Kann mir jemand sagen, wie ich die Callback-Funktion in einer Klasse bekannt machen kann? Ich habe es versucht mit:</p>
<pre><code class="language-cpp">wc.lpfnWndProc = WndProc;
</code></pre>
<p>Doch das gibt bei mir immer folgende zwei Fehler:</p>
<pre><code class="language-cpp">------ Erstellen gestartet: Projekt: MyEngine, Konfiguration: Debug Win32 ------
Kompilieren...
CreateWindow.cpp
c:\dokumente und einstellungen\patrick\eigene dateien\visual studio 2008\projects\myengine\myengine\createwindow.cpp(15) : error C3867: &quot;CWindow::WndProc&quot;: Dem Funktionsaufruf fehlt die Argumentliste. Verwenden Sie &quot;&amp;CWindow::WndProc&quot;, um einen Zeiger auf den Member zu erstellen.
c:\dokumente und einstellungen\patrick\eigene dateien\visual studio 2008\projects\myengine\myengine\createwindow.cpp(15) : error C2440: '=': 'LRESULT (__stdcall CWindow::* )(HWND,UINT,WPARAM,LPARAM)' kann nicht in 'WNDPROC' konvertiert werden
        Es gibt keinen Kontext, in dem diese Konvertierung möglich ist
Das Buildprotokoll wurde unter &quot;file://c:\Dokumente und Einstellungen\patrick\Eigene Dateien\Visual Studio 2008\Projects\MyEngine\MyEngine\Debug\BuildLog.htm&quot; gespeichert.
MyEngine - 2 Fehler, 0 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
</code></pre>
<p>Hier ist der vollständige Code:</p>
<pre><code class="language-cpp">// CreateWindow.h
//
// Die Funktionen und Variabeln definieren
//
#include &lt;windows.h&gt;

// Klasse erzeugen
//
class CWindow
{
public:

	HWND CreateWindowME (HINSTANCE hInstance, LPCSTR WindowTitle);
	LRESULT WINAPI WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

};

// Zeiger erzeugen
//
CWindow Window;
CWindow * pWindow = &amp;Window;

// CreateWindow.cpp
//
// Die Funktionen und Variabeln deklarieren
//
#include &quot;CreateWindow.h&quot;

HWND CWindow::CreateWindowME (HINSTANCE hInstance, LPCSTR WindowTitle)
{
	WNDCLASSEX wc;

	wc.cbSize = sizeof (WNDCLASSEX);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.hInstance = hInstance;
	wc.lpfnWndProc = WndProc;
	wc.cbWndExtra = 0;
	wc.cbClsExtra = 0;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = &quot;My Engine&quot;;
	wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
	wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
	wc.hCursor = LoadCursor (NULL, IDC_ARROW);
	wc.hIconSm = LoadIcon (NULL, IDI_APPLICATION);

	if (!RegisterClassEx (&amp;wc))
	{
		MessageBox (NULL, &quot;Fehler beim registrieren des Fensters!&quot;, &quot;Fehler aufgetreten&quot;,
					MB_OK | MB_ICONEXCLAMATION);

		return (0);
	}

	return (CreateWindowEx (NULL,
							&quot;My Engine&quot;,
							WindowTitle,
							WS_OVERLAPPEDWINDOW | WS_VISIBLE,
							100, 100,
							500, 500,
							NULL,
							NULL,
							hInstance,
							NULL));
}

LRESULT WINAPI CWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_CREATE:
		{
			return (0);
		} break;

		case WM_DESTROY:
		{
	             PostQuitMessage(0);
				 return (0);
		} break;

		default:
		{
		}break;
	}

	return DefWindowProc (hwnd, msg, wParam, lParam);
}
</code></pre>
<p>Weiss jemand, was ich falsch gemacht habe?</p>
<p>Ich freue mich auf eure Antworten!</p>
<p>Gruss Patrick</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/236158/wie-kann-ich-callback-funktion-in-einer-klasse-bekannt-machen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 23:05:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/236158.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Mar 2009 14:29:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 14:29:48 GMT]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>Kann mir jemand sagen, wie ich die Callback-Funktion in einer Klasse bekannt machen kann? Ich habe es versucht mit:</p>
<pre><code class="language-cpp">wc.lpfnWndProc = WndProc;
</code></pre>
<p>Doch das gibt bei mir immer folgende zwei Fehler:</p>
<pre><code class="language-cpp">------ Erstellen gestartet: Projekt: MyEngine, Konfiguration: Debug Win32 ------
Kompilieren...
CreateWindow.cpp
c:\dokumente und einstellungen\patrick\eigene dateien\visual studio 2008\projects\myengine\myengine\createwindow.cpp(15) : error C3867: &quot;CWindow::WndProc&quot;: Dem Funktionsaufruf fehlt die Argumentliste. Verwenden Sie &quot;&amp;CWindow::WndProc&quot;, um einen Zeiger auf den Member zu erstellen.
c:\dokumente und einstellungen\patrick\eigene dateien\visual studio 2008\projects\myengine\myengine\createwindow.cpp(15) : error C2440: '=': 'LRESULT (__stdcall CWindow::* )(HWND,UINT,WPARAM,LPARAM)' kann nicht in 'WNDPROC' konvertiert werden
        Es gibt keinen Kontext, in dem diese Konvertierung möglich ist
Das Buildprotokoll wurde unter &quot;file://c:\Dokumente und Einstellungen\patrick\Eigene Dateien\Visual Studio 2008\Projects\MyEngine\MyEngine\Debug\BuildLog.htm&quot; gespeichert.
MyEngine - 2 Fehler, 0 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
</code></pre>
<p>Hier ist der vollständige Code:</p>
<pre><code class="language-cpp">// CreateWindow.h
//
// Die Funktionen und Variabeln definieren
//
#include &lt;windows.h&gt;

// Klasse erzeugen
//
class CWindow
{
public:

	HWND CreateWindowME (HINSTANCE hInstance, LPCSTR WindowTitle);
	LRESULT WINAPI WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

};

// Zeiger erzeugen
//
CWindow Window;
CWindow * pWindow = &amp;Window;

// CreateWindow.cpp
//
// Die Funktionen und Variabeln deklarieren
//
#include &quot;CreateWindow.h&quot;

HWND CWindow::CreateWindowME (HINSTANCE hInstance, LPCSTR WindowTitle)
{
	WNDCLASSEX wc;

	wc.cbSize = sizeof (WNDCLASSEX);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.hInstance = hInstance;
	wc.lpfnWndProc = WndProc;
	wc.cbWndExtra = 0;
	wc.cbClsExtra = 0;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = &quot;My Engine&quot;;
	wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
	wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
	wc.hCursor = LoadCursor (NULL, IDC_ARROW);
	wc.hIconSm = LoadIcon (NULL, IDI_APPLICATION);

	if (!RegisterClassEx (&amp;wc))
	{
		MessageBox (NULL, &quot;Fehler beim registrieren des Fensters!&quot;, &quot;Fehler aufgetreten&quot;,
					MB_OK | MB_ICONEXCLAMATION);

		return (0);
	}

	return (CreateWindowEx (NULL,
							&quot;My Engine&quot;,
							WindowTitle,
							WS_OVERLAPPEDWINDOW | WS_VISIBLE,
							100, 100,
							500, 500,
							NULL,
							NULL,
							hInstance,
							NULL));
}

LRESULT WINAPI CWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_CREATE:
		{
			return (0);
		} break;

		case WM_DESTROY:
		{
	             PostQuitMessage(0);
				 return (0);
		} break;

		default:
		{
		}break;
	}

	return DefWindowProc (hwnd, msg, wParam, lParam);
}
</code></pre>
<p>Weiss jemand, was ich falsch gemacht habe?</p>
<p>Ich freue mich auf eure Antworten!</p>
<p>Gruss Patrick</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678054</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678054</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 14:29:48 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 14:59:51 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">wc.lpfnWndProc = ::WndProc;
</code></pre>
<pre><code class="language-cpp">LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{
	return Window.WndProc(xxx);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1678082</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678082</guid><dc:creator><![CDATA[sapero]]></dc:creator><pubDate>Wed, 11 Mar 2009 14:59:51 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 15:36:11 GMT]]></title><description><![CDATA[<p>Das geht ja gar nicht, denn ich habe bei WndProc schon ein Rückgabewert, nämlich:</p>
<pre><code class="language-cpp">return DefWindowProc (hwnd, msg, wParam, lParam);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1678129</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678129</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 15:36:11 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 16:15:19 GMT]]></title><description><![CDATA[<p>schonmal was vom this aka noob-zeiger gehört?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678171</guid><dc:creator><![CDATA[asdca]]></dc:creator><pubDate>Wed, 11 Mar 2009 16:15:19 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 16:23:10 GMT]]></title><description><![CDATA[<p>Mit dem this-Zeiger kommen immer noch Fehler!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678184</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678184</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 16:23:10 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 16:29:23 GMT]]></title><description><![CDATA[<p>orz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678194</guid><dc:creator><![CDATA[asdca]]></dc:creator><pubDate>Wed, 11 Mar 2009 16:29:23 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 16:51:30 GMT]]></title><description><![CDATA[<p>Kann mir jemand eine richtige Antwort geben, evtl. mit Codebeispiel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678220</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 16:51:30 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 17:02:09 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// TestWin.cpp : Defines the entry point for the application.
//

#include &quot;stdafx.h&quot;
#include &quot;resource.h&quot;

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;								// current instance
TCHAR szTitle[MAX_LOADSTRING];								// The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];								// The title bar text

// Foward declarations of functions included in this code module:
ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK	About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_TESTWIN, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow)) 
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTWIN);

	// Main message loop:
	while (GetMessage(&amp;msg, NULL, 0, 0)) 
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &amp;msg)) 
		{
			TranslateMessage(&amp;msg);
			DispatchMessage(&amp;msg);
		}
	}

	return msg.wParam;
}

//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage is only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX); 

	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon(hInstance, (LPCTSTR)IDI_TESTWIN);
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName	= (LPCSTR)IDC_TESTWIN;
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

	return RegisterClassEx(&amp;wcex);
}

//
//   FUNCTION: InitInstance(HANDLE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	TCHAR szHello[MAX_LOADSTRING];
	LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_\1:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &amp;ps);
			// TODO: Add any drawing code here...
			RECT rt;
			GetClientRect(hWnd, &amp;rt);
			DrawText(hdc, szHello, strlen(szHello), &amp;rt, DT_CENTER);
			EndPaint(hWnd, &amp;ps);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_INITDIALOG:
				return TRUE;

		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			}
			break;
	}
    return FALSE;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1678227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678227</guid><dc:creator><![CDATA[asdca]]></dc:creator><pubDate>Wed, 11 Mar 2009 17:02:09 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 17:13:23 GMT]]></title><description><![CDATA[<p>Du arbeitest in diesem Codebeispiel gar nicht mit Klassen, und was ich wissen will, ist, wie man die Callback-Funktion in einer Klasse bekannt machen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678235</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678235</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 17:13:23 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 18:51:00 GMT]]></title><description><![CDATA[<p>Das Problem ist, dass als erster Parameter deiner Memberfunktionen in der CWindow Klasse immer implizit der this-Zeiger mitgegeben wird.<br />
Allerdings verlangt</p>
<pre><code class="language-cpp">wc.lpfnWndProc
</code></pre>
<p>eine Funktion mit der Signatur</p>
<pre><code class="language-cpp">(HWND, UINT, WPARAM, LPARAM)
</code></pre>
<p>erwartet, du mit deinem Code aber implizit solch eine Signatur bekommst:</p>
<pre><code class="language-cpp">(CWindow*, HWND, UINT, WPARAM, LPARAM)
</code></pre>
<p>Schau mal ins WINAPI-FAQ. Dort, ziemlich am Ende wird dein Problem mit Lösungsvorschlägen behandelt.</p>
<p>EDIT: Habs zwar nicht getestet, aber saperos Vorschlag müsste AFAIK funktionieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678239</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Wed, 11 Mar 2009 18:51:00 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 19:54:18 GMT]]></title><description><![CDATA[<p>Ich sehe leider unter der folgenden Seite <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39356-and-postdays-is-0-and-postorder-is-asc-and-start-is-0.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39356-and-postdays-is-0-and-postorder-is-asc-and-start-is-0.html</a> keinen saperos.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678319</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678319</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 19:54:18 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 20:09:45 GMT]]></title><description><![CDATA[<p>Ich meinte hier in deinem Beitrag hat dir separo einen Lösungsvorschlag unterbreitet, worauf du geschrieben hattest, dass das nicht gehen würde, weil WndProc schon einen Rüchgabewert hätte, nämlich</p>
<pre><code class="language-cpp">return DefWindowProc(hwnd, msg, wparam, lparam)
</code></pre>
<p>Probier es mal so aus, wie separo es geschrieben hat. Müsste funktionieren. Dein Einwand mit dem Rüchgabewert ist falsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678324</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678324</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Wed, 11 Mar 2009 20:09:45 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 20:53:15 GMT]]></title><description><![CDATA[<p>Nun kommt noch einen Fehler, nämlich 'xxx': nichtdeklarierter Bezeichner.</p>
<p>Was habe ich nun falsch gemacht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678345</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678345</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 20:53:15 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 21:06:40 GMT]]></title><description><![CDATA[<p>Ei ei ei, unter Umständen würde ich dir erstmal ein Tutorial und/oder ein Buch zum Programmieren mit C/C++ empfehlen.</p>
<p>Ersetze</p>
<pre><code class="language-cpp">return Window.WndProc(xxx);
</code></pre>
<p>durch</p>
<pre><code class="language-cpp">return Window.WndProc(hwnd, msg, wparam, lparam);
</code></pre>
<p>EDIT: Ich seh grad' das könnt etwas unverständlich bzw. ungenau formuliert sein. Also:</p>
<p>In deiner Klasse hast du eine Memberfunktion</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
//dein Code
}
</code></pre>
<p>deklariert und definiert. Diese lässt du so stehen, wie du es in deinem ersten Post geschrieben hast.</p>
<p>Du brauchst aber noch eine Funktion außerhalb deiner Klasse, nämlich:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
    return Window.WndProc(hwnd, msg, wparam, lparam);
}
</code></pre>
<p>So, jetzt müsstest du wahrscheinlich</p>
<pre><code class="language-cpp">CWindow Window;
</code></pre>
<p>auch noch global deklarieren, dann sollte alles funktionieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678350</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Wed, 11 Mar 2009 21:06:40 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 21:04:39 GMT]]></title><description><![CDATA[<p>Ich habe bereits vier Bücher über das Programmieren, und eines habe ich 2 mal komplett durchgelesen. Ich weiss, ich bin in der WinAPI noch nicht so drin.</p>
<p>Ich habe nun diese (xxx) durch (hwnd, msg, wParam, lParam) ersetzt. Doch jetzt kommen drei weitere Fehler:</p>
<pre><code class="language-cpp">------ Erstellen gestartet: Projekt: MyEngine, Konfiguration: Debug Win32 ------
Kompilieren...
CreateWindow.cpp
Verknüpfen...
CreateWindow.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@YGJPAUHWND__@@IIJ@Z)&quot; in Funktion &quot;&quot;public: struct HWND__ * __thiscall CWindow::InitWindow(char const *,int,int,int,int)&quot; (?InitWindow@CWindow@@QAEPAUHWND__@@PBDHHHH@Z)&quot;.
MSVCRTD.lib(crtexew.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;_WinMain@16&quot; in Funktion &quot;___tmainCRTStartup&quot;.
C:\Dokumente und Einstellungen\patrick\Eigene Dateien\Visual Studio 2008\Projects\MyEngine\Debug\MyEngine.exe : fatal error LNK1120: 2 nicht aufgelöste externe Verweise.
Das Buildprotokoll wurde unter &quot;file://c:\Dokumente und Einstellungen\patrick\Eigene Dateien\Visual Studio 2008\Projects\MyEngine\MyEngine\Debug\BuildLog.htm&quot; gespeichert.
MyEngine - 3 Fehler, 0 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
</code></pre>
<p>Den Code habe ich nochmals hier:</p>
<pre><code class="language-cpp">// CreateWindow.h
//
// Die Funktionen und Variabeln definieren
//
#ifndef CREATEWINDOW_H
#define CREATEWINDOW_H

#include &lt;windows.h&gt;

class CWindow

{

public:

	HWND InitWindow (LPCTSTR WindowTitle, int XPos, int YPos, int WindowWidth, int WindowHeight);
	LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
	int g_WindowWidth;
	int g_WindowHeight;

private:

};

const char g_szClassName [] = &quot;My Window&quot;;

// Zeiger erzeugen
//
CWindow Window;
CWindow * pWindow = &amp;Window;

#endif

// CreateWindow.cpp
//
// Die Funktionen und Variablen deklarieren
//
#include &quot;CreateWindow.h&quot;

LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

HWND CWindow::InitWindow (LPCTSTR WindowTitle, int XPos, int YPos, int WindowWidth, int WindowHeight)

{

	WNDCLASSEX wc;
	HWND hwnd;

	ZeroMemory (&amp;wc, sizeof (WNDCLASSEX));

	wc.cbSize = sizeof (WNDCLASSEX);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = ::WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = GetModuleHandle (NULL);
	wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
	wc.hCursor = LoadCursor (NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject (BLACK_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = g_szClassName;
	wc.hIconSm = LoadIcon (NULL, IDI_APPLICATION);

	RegisterClassEx (&amp;wc);

	hwnd = CreateWindowEx (NULL,
						   g_szClassName,
						   WindowTitle,
						   WS_VISIBLE | WS_EX_TOPMOST | WS_POPUP,
						   XPos, YPos,
						   WindowWidth, WindowHeight,
						   NULL,
						   NULL, 
						   GetModuleHandle(NULL),
						   NULL);

	g_WindowWidth = WindowWidth;
	g_WindowHeight = WindowHeight;

	return 0;
}

LRESULT CALLBACK CWindow::WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_DESTROY:
		{
			PostQuitMessage (0);
			return (0);
		} break;
	}

	return Window.WndProc (hwnd, msg, wParam, lParam); 
}
</code></pre>
<p>Weisst du was ich hier falsch gemacht habe?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678352</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678352</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 21:04:39 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 21:11:41 GMT]]></title><description><![CDATA[<p>okay okay, ich hack das mal schnell bei mir ein und guck mal weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678358</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Wed, 11 Mar 2009 21:11:41 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 21:16:23 GMT]]></title><description><![CDATA[<p>Okay, danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678362</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678362</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 21:16:23 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 21:29:28 GMT]]></title><description><![CDATA[<p>So funktioniert es bei mir einwandfrei:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

class CWindow {
	public:
		HWND InitWindow (LPCTSTR, int, int, int, int);
		LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
		int g_WindowWidth;
		int g_WindowHeight;
};

const char g_szClassName [] = &quot;My Window&quot;;

CWindow Window;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
	return Window.WndProc(hwnd, msg, wparam, lparam);
}

HWND CWindow::InitWindow (LPCTSTR WindowTitle, int XPos, int YPos, int WindowWidth, int WindowHeight) {
    WNDCLASSEX wc;
    HWND hwnd;

    ZeroMemory (&amp;wc, sizeof (WNDCLASSEX));

    wc.cbSize = sizeof (WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = ::WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = GetModuleHandle (NULL);
    wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor (NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject (BLACK_BRUSH);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = g_szClassName;
    wc.hIconSm = LoadIcon (NULL, IDI_APPLICATION);

    RegisterClassEx (&amp;wc);

    hwnd = CreateWindowEx (0,
                           g_szClassName,
                           WindowTitle,
                           WS_VISIBLE | WS_EX_TOPMOST | WS_POPUP,
                           XPos, YPos,
                           WindowWidth, WindowHeight,
                           NULL,
                           NULL,
                           GetModuleHandle(NULL),
                           NULL);

    g_WindowWidth = WindowWidth;
    g_WindowHeight = WindowHeight;

    return 0;
}

LRESULT CALLBACK CWindow::WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
        case WM_DESTROY:
        {
            PostQuitMessage (0);
            return (0);
        } break;
    }

    return DefWindowProc(hwnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	Window.InitWindow(&quot;Test&quot;, 150, 150, 275, 275);

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

	return 0;
}
</code></pre>
<p>EDIT: Achja nochwas. Ich wollte nicht pampig sein oder so wegen dem &quot;Du solltest mal ein Buch lesen bzgl. der C/C++ Programmierung&quot;, aber eigentlich sollte es klar sein, dass man das</p>
<pre><code class="language-cpp">return Window.WndProc(xxx);
</code></pre>
<p>nicht einfach so übernehemn kann. Hat ja nichts speziell mit der WINAPI zu tun.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678369</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Wed, 11 Mar 2009 21:29:28 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 21:35:53 GMT]]></title><description><![CDATA[<p>Bei mir gibt es jetzt noch folgende zwei Fehler:</p>
<pre><code class="language-cpp">Kompilieren...
CreateWindow.cpp
Verknüpfen...
MSVCRTD.lib(crtexew.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;_WinMain@16&quot; in Funktion &quot;___tmainCRTStartup&quot;.
C:\Dokumente und Einstellungen\patrick\Eigene Dateien\Visual Studio 2008\Projects\MyEngine\Debug\MyEngine.exe : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.
Das Buildprotokoll wurde unter &quot;file://c:\Dokumente und Einstellungen\patrick\Eigene Dateien\Visual Studio 2008\Projects\MyEngine\MyEngine\Debug\BuildLog.htm&quot; gespeichert.
MyEngine - 2 Fehler, 0 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
</code></pre>
<p>Ich habe dein Beispiel komplett übernommen, ausser das ich die Klasse in eine Header-Detei geschrieben habe. Was habe ich nun falsch, Projekteinstellungen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678378</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Wed, 11 Mar 2009 21:35:53 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 21:44:06 GMT]]></title><description><![CDATA[<p>Also das Program an sich sollte korrekt sein. Wahrscheinlich ist wirklich bei den Projekteinstellungen etwas noch falsch und/oder unvollständig.</p>
<p>Hast du eingestellt, dass eine GUI-Anwendung erstellt werden soll (was aber eigentlich auch keine Probleme geben sollte, wenn man es nicht angibt, dann erscheint halt noch zusätzlich ein Konsolenfenster) und alle benötigten Libs eingebunden (User32.lib, Kernel32.lib oder was weiß ich alles).</p>
<p>Ich selbst programmiere mit Codeblocks, von daher weiß ich nicht inwiefern man was bei deiner Entwicklungsumgebung beachten muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678379</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678379</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Wed, 11 Mar 2009 21:44:06 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 22:11:05 GMT]]></title><description><![CDATA[<p>Mit welcher Entwicklungsumgebung programmierst du?<br />
Hab auf MSDN mal deinen Fehlercode eingegeben und da irgendwas mit MFC-Anwendung und Unicode gelesen.</p>
<p>Kenn mich mit der MFC nicht sonderlich aus, aber da wird AFAIK schon CWindow definiert.</p>
<p>Ich kann dir da leider nicht weiterhelfen, aber könntest du mal deine Klasse umbenennen, von CWindow in MyWindow oder sowas. Das ist mein letzter Strohhalm <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678393</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678393</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Wed, 11 Mar 2009 22:11:05 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Wed, 11 Mar 2009 22:26:46 GMT]]></title><description><![CDATA[<p><code>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)</code><br />
<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="➡"
    /><br />
<code>int WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )</code><br />
Sollte es bringen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678400</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678400</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Wed, 11 Mar 2009 22:26:46 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Thu, 12 Mar 2009 17:00:05 GMT]]></title><description><![CDATA[<p>Ich programmiere unter Visual C++ Express 2008, WinAPI.</p>
<p>Ich habe nun die Klasse umbenannt, auf MyWindow. Ich erstelle gar keine WinMain-Funktion, da ich dieses Programm als Engine verwende. Dann kann ich per #include die Dateien einlesen. Und dann erstelle ich eine WinMain-Funktion, daher konnte ich keine abstände machen zwieschen Klammer und HINSTANCE.</p>
<p>Doch es gibt auch mit MyWindow noch die selben Fehler.</p>
<p>Was habe ich denn falsch gemacht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678832</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Thu, 12 Mar 2009 17:00:05 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Thu, 12 Mar 2009 17:35:29 GMT]]></title><description><![CDATA[<p>Okay, dann hast du ja eigentlich alles.</p>
<p>Also in deiner CreateWindow.h sollte nun stehen:</p>
<pre><code class="language-cpp">#ifndef CREATEWINDOW_H
#define CREATEWINDOW_H

#include &lt;windows.h&gt;

class CWindow {
	public:
		HWND InitWindow (LPCTSTR, int, int, int, int);
		LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
		int g_WindowWidth;
		int g_WindowHeight;
};

const char g_szClassName [] = &quot;My Window&quot;;

CWindow Window;

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

#endif
</code></pre>
<p>Und in deiner CreateWindow.cpp sollte stehen:</p>
<pre><code class="language-cpp">#include &quot;CreateWindow.h&quot;

HWND CWindow::InitWindow (LPCTSTR WindowTitle, int XPos, int YPos, int WindowWidth, int WindowHeight) {
    WNDCLASSEX wc;
    HWND hwnd;

    ZeroMemory (&amp;wc, sizeof (WNDCLASSEX));

    wc.cbSize = sizeof (WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = ::WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = GetModuleHandle (NULL);
    wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor (NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject (BLACK_BRUSH);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = g_szClassName;
    wc.hIconSm = LoadIcon (NULL, IDI_APPLICATION);

    RegisterClassEx (&amp;wc);

    hwnd = CreateWindowEx (0,
                           g_szClassName,
                           WindowTitle,
                           WS_VISIBLE | WS_EX_TOPMOST | WS_POPUP,
                           XPos, YPos,
                           WindowWidth, WindowHeight,
                           NULL,
                           NULL,
                           GetModuleHandle(NULL),
                           NULL);

    g_WindowWidth = WindowWidth;
    g_WindowHeight = WindowHeight;

    return 0;
}

LRESULT CALLBACK CWindow::WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
        case WM_DESTROY:
        {
            PostQuitMessage (0);
            return (0);
        } break;
    }

    return DefWindowProc(hwnd, msg, wParam, lParam);
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
    return Window.WndProc(hwnd, msg, wparam, lparam);
}
</code></pre>
<p>Das Umbenennen der Klasse von CWindow in MyWindow war höchstwahrscheinlich unnötig, sorry, aber wusste mir da grad nicht weiterzuhelfen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Nun hast du ja alles und so sollte alles passen. Natürlich wird aus diesen zwei Dateien keine EXE und auch keine LIB erzeugt (solange du nicht in den Projekteinstellungen angegeben hast, eine LIB zu erzeugen).</p>
<p>Nun kannst du den Header CreateWindow.h in deine Programme includen, die Quelldatei CreateWindow.cpp deinen Projekten hinzufügen und somit deine Klasse CWindow in deinen Programmen verwenden.</p>
<p>So, das müsste es gewesen sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678854</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Thu, 12 Mar 2009 17:35:29 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Thu, 12 Mar 2009 18:06:53 GMT]]></title><description><![CDATA[<p>Ich habe nun alles so übernommen, aber es gibt immer noch die selben Fehler.</p>
<p>Wie kann man denn in den Projekteinstellungen auswählen, dass eine Lib erstellt werden soll?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678870</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Thu, 12 Mar 2009 18:06:53 GMT</pubDate></item><item><title><![CDATA[Reply to Wie kann ich Callback-Funktion in einer Klasse bekannt machen? on Thu, 12 Mar 2009 18:45:40 GMT]]></title><description><![CDATA[<p>Hast du die zwei Dateien in einem anderen Projekt verwendet, oder versuchst du Createwindow.cpp allein zu kompilieren (zu einer static library, was ich vorher flax LIB genannt habe)?</p>
<p>Im ersten Fall kann ich dir nicht helfen. Wenn du in deiner main.cpp (dort wo die WinMain-Funktion deines Projekts steht) die Createwindow.h included hast und Createwindow.cpp dem Projekt hinzugefügt hast und noch eventuell benötigte Bibliotheken wie user32.lib und kernel32.lib dem Projekt mitgeteilt hast und du trotzdem noch Fehlermeldungen bekommst kann ich dir nicht helfen. Eigentlich müsste das funzen.</p>
<p>Zweiter Fall: Du hast also ein Projekt erstellt, in dem nur die beiden Dateien Createwindow.h und Createwindow.cpp vorhanden sind. Daraus möchtest du wohl jetzt eine static library machen? Dafür musst du in deinen Projekteinstellungen nachsehen, &quot;zu was dein Projekt kompiliert werden soll&quot;. In Codeblocks (der Entwicklungsumgebung, die ich verwende), sieht man beispielsweise ein Auswahlfeld, aus dem man wählen kann, ob man das Projekt zu einer</p>
<p>-Konsolenanwendung<br />
-GUI-Anwendung<br />
-DLL<br />
-static library<br />
-nativ irgendwas<br />
-nur commands irgendwas</p>
<p>kompilieren lassen möchte. Dort müsste man static library auswählen. Dann würde aus Createwindow.cpp (mit inkludierter Createwindow.h) nämlich die static library &quot;libCreatewindow.a&quot; kompiliert.<br />
Ich weiß nicht, wie das bei VC aussieht, aber da wird es wahrscheinlich eine ähnliche Einstellungsmöglichkeit geben, musst du halt mal gucken.</p>
<p>Ich hoffe ich konnte dir ein bisschen weiterhelfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1678874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1678874</guid><dc:creator><![CDATA[Bier]]></dc:creator><pubDate>Thu, 12 Mar 2009 18:45:40 GMT</pubDate></item></channel></rss>