<?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[Anfänger: Was ist falsch?]]></title><description><![CDATA[<p>Hallo ich lerne gerade durch ein <a href="http://www.win-api.de/tutorials.php" rel="nofollow">Tutorial</a> WinAPI nur ich habe hier einen Fehler:</p>
<pre><code>E:\dokumente\C++\projekte\WinAPI\Fenster1\main.cpp In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':
62 E:\dokumente\C++\projekte\WinAPI\Fenster1\main.cpp a function-definition is not allowed here before '{' token
62 E:\dokumente\C++\projekte\WinAPI\Fenster1\main.cpp expected `,' or `;' before '{' token
E:\dokumente\C++\projekte\WinAPI\Fenster1\Makefile.win [Build Error]  [main.o] Error 1
</code></pre>
<p>Code:</p>
<pre><code>#define STRICT
#include &lt;windows.h&gt;

//LRESULT ist ein typedef auf einen long Typ.
//CALLBACK ist genau das gleiche wie WINAPI, CALLBACK sagt aus, dass diese Funktion von Windows aufgerufen wird.
//HWND = Handle zu dem Fenster, für das die Nachricht bestimmt ist.
//UINT = enthält die Kennziffer der Nachricht, für alle Nachrichten sind in winuser.h Konstanten deklariert
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

//Programmnamen
const char szAppName[] = &quot;Ein eigenes Fenster&quot;;

//In jedem Windows API Programm brauchen wir die WinMain Funktion
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){

    HWND       hWnd; //Handle für das Fenster.
    MSG        msg;  //Windows Nachrichten abholen und bearbeiten.
    WNDCLASS   wc;   //Typ der Fensterklasse.

    wc.style         =  CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc   =  WndProc;
    wc.cbClsExtra    =  0;
    wc.cbWndExtra    =  0;
    wc.hInstance     =  hInstance;                           //Handle zu unserer Programminstanz, damit nur unser Programm diese Fensterklasse benutzen kann.
    wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);          //Typ des Cursors.
    wc.hIcon         =  LoadIcon(NULL,IDI_APPLICATION);
    wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH); //Hintergrundfarbe
    wc.lpszClassName =  szAppName;                           //Fenstername
    wc.lpszMenuName  =  NULL;                                //Menü

    RegisterClass(&amp;wc); //registriert bzw. meldet unsere Fensterklasse beim Fenstermanager von Windows an.

    hWnd = CreateWindow(szAppName,              //Fenstername
                        &quot;Titelleiste&quot;,          //Text der Titelleiste
                        WS_OVERLAPPEDWINDOW,    //Stil des Fensters
                        CW_USEDEFAULT,          //X-Position auf dem Monitor
                        CW_USEDEFAULT,          //Y-Position auf dem Monitor
                        CW_USEDEFAULT,          //Fensterbreite
                        CW_USEDEFAULT,          //Fensterhoehe
                        NULL,
                        NULL,
                        hInstance,              //Handle auf unsere Programm Instanz
                        NULL);

    //Zeigt das Fenster an.
    //hWnd     = Handle auf unser Fenster.
    //iCmdShow = Wie das Fenster angezeigt werden soll(z.b. SW_SHOW)        
    ShowWindow(hWnd, iCmdShow);
    //Lässt den Anwendungsbereich, also den freien Fensterbereich, sofort nach dem Start neu zeichnen.
    //hWnd     = Handle auf unser Fenster.
    UpdateWindow(hWnd);

    //GetMessage(&amp;msg, NULL, 0, 0):
    //Nachrichten aus der Warteschleife holen.
    //&amp;msg = Gespeicherte Nachricht.
    while(GetMessage(&amp;msg, NULL, 0, 0)){
                           TranslateMessage(&amp;msg);
                           DispatchMessage(&amp;msg);
    }

   return msg.wParam;
   LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ //ZEILE 62!!!!
     switch(message){
       case WM_DESTROY:{
         PostQuitMessage(0);
         return 0;
       }
     }

     return DefWindowProc(hWnd, message, wParam, lParam);
   }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/145619/anfänger-was-ist-falsch</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 00:49:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/145619.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Apr 2006 16:29:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anfänger: Was ist falsch? on Sat, 29 Apr 2006 16:29:15 GMT]]></title><description><![CDATA[<p>Hallo ich lerne gerade durch ein <a href="http://www.win-api.de/tutorials.php" rel="nofollow">Tutorial</a> WinAPI nur ich habe hier einen Fehler:</p>
<pre><code>E:\dokumente\C++\projekte\WinAPI\Fenster1\main.cpp In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':
62 E:\dokumente\C++\projekte\WinAPI\Fenster1\main.cpp a function-definition is not allowed here before '{' token
62 E:\dokumente\C++\projekte\WinAPI\Fenster1\main.cpp expected `,' or `;' before '{' token
E:\dokumente\C++\projekte\WinAPI\Fenster1\Makefile.win [Build Error]  [main.o] Error 1
</code></pre>
<p>Code:</p>
<pre><code>#define STRICT
#include &lt;windows.h&gt;

//LRESULT ist ein typedef auf einen long Typ.
//CALLBACK ist genau das gleiche wie WINAPI, CALLBACK sagt aus, dass diese Funktion von Windows aufgerufen wird.
//HWND = Handle zu dem Fenster, für das die Nachricht bestimmt ist.
//UINT = enthält die Kennziffer der Nachricht, für alle Nachrichten sind in winuser.h Konstanten deklariert
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

//Programmnamen
const char szAppName[] = &quot;Ein eigenes Fenster&quot;;

//In jedem Windows API Programm brauchen wir die WinMain Funktion
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){

    HWND       hWnd; //Handle für das Fenster.
    MSG        msg;  //Windows Nachrichten abholen und bearbeiten.
    WNDCLASS   wc;   //Typ der Fensterklasse.

    wc.style         =  CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc   =  WndProc;
    wc.cbClsExtra    =  0;
    wc.cbWndExtra    =  0;
    wc.hInstance     =  hInstance;                           //Handle zu unserer Programminstanz, damit nur unser Programm diese Fensterklasse benutzen kann.
    wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);          //Typ des Cursors.
    wc.hIcon         =  LoadIcon(NULL,IDI_APPLICATION);
    wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH); //Hintergrundfarbe
    wc.lpszClassName =  szAppName;                           //Fenstername
    wc.lpszMenuName  =  NULL;                                //Menü

    RegisterClass(&amp;wc); //registriert bzw. meldet unsere Fensterklasse beim Fenstermanager von Windows an.

    hWnd = CreateWindow(szAppName,              //Fenstername
                        &quot;Titelleiste&quot;,          //Text der Titelleiste
                        WS_OVERLAPPEDWINDOW,    //Stil des Fensters
                        CW_USEDEFAULT,          //X-Position auf dem Monitor
                        CW_USEDEFAULT,          //Y-Position auf dem Monitor
                        CW_USEDEFAULT,          //Fensterbreite
                        CW_USEDEFAULT,          //Fensterhoehe
                        NULL,
                        NULL,
                        hInstance,              //Handle auf unsere Programm Instanz
                        NULL);

    //Zeigt das Fenster an.
    //hWnd     = Handle auf unser Fenster.
    //iCmdShow = Wie das Fenster angezeigt werden soll(z.b. SW_SHOW)        
    ShowWindow(hWnd, iCmdShow);
    //Lässt den Anwendungsbereich, also den freien Fensterbereich, sofort nach dem Start neu zeichnen.
    //hWnd     = Handle auf unser Fenster.
    UpdateWindow(hWnd);

    //GetMessage(&amp;msg, NULL, 0, 0):
    //Nachrichten aus der Warteschleife holen.
    //&amp;msg = Gespeicherte Nachricht.
    while(GetMessage(&amp;msg, NULL, 0, 0)){
                           TranslateMessage(&amp;msg);
                           DispatchMessage(&amp;msg);
    }

   return msg.wParam;
   LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ //ZEILE 62!!!!
     switch(message){
       case WM_DESTROY:{
         PostQuitMessage(0);
         return 0;
       }
     }

     return DefWindowProc(hWnd, message, wParam, lParam);
   }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1047889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047889</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Sat, 29 Apr 2006 16:29:15 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger: Was ist falsch? on Sat, 29 Apr 2006 16:35:21 GMT]]></title><description><![CDATA[<p>Ich hab denn Fehler gefunden <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="😃"
    /> also kann gelöscht oder gesperrt werden, danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1047893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047893</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Sat, 29 Apr 2006 16:35:21 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger: Was ist falsch? on Sun, 30 Apr 2006 18:45:53 GMT]]></title><description><![CDATA[<p>Also ich weis nicht was hier falsch sein soll:</p>
<pre><code>#define STRICT
#include &lt;windows.h&gt;

//LRESULT ist ein typedef auf einen long Typ.
//CALLBACK sagt aus, dass diese Funktion von Windows aufgerufen wird.
//Der erste Parameter ist der Handle zu dem Fenster.
//Der zweite Parameter message enthält die Kennziffer der Nachricht.
//Die nächsten beiden Parameter enthalten je nach Nachricht verschiedene Daten.
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 

const char szAppName[] = &quot;Ein eigenes Fenster&quot;; //Programmname.

//Der erste Parameter HINSTANCE ist ein Handle auf diese Programminstanz.
//Der zweite Parameter ist vom gleichen Typ, jedoch wird dieser Wert in Win 32 immer Null sein.
//Der dritte Parameter enthält die Kommandozeilen Parameter.
//Mit dem vierten Parameter wird übergeben, wie das eventuelle Fenster angezeigt werden soll (maximiert, minimiert usw.).
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){
	HWND       hWnd; //Handle für unser Fenster.
	MSG        msg;  //Windows Nachrichten abholen und bearbeiten.
	WNDCLASS   wc;   //Typ der Fensterklasse.

	wc.style         =  CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc   =  WndProc;
	wc.cbClsExtra    =  0;
    wc.cbWndExtra    =  0;
	wc.hInstance     =  hInstance;
    wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
    wc.hIcon         =  LoadIcon(NULL,IDI_APPLICATION);
    wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszClassName =  szAppName;
    wc.lpszMenuName  =  NULL;
	RegisterClass(&amp;wc);

	hWnd = CreateWindow(szAppName,
                        &quot;Titelleiste&quot;,
                        WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT,          /* X-Position auf dem Monitor */
                        CW_USEDEFAULT,          /* Y-Position auf dem Monitor */
                        CW_USEDEFAULT,          /* Fensterbreite              */
                        CW_USEDEFAULT,          /* Fensterhoehe               */
                        NULL,
                        NULL,
                        hInstance,
                        NULL);

	ShowWindow(hWnd, iCmdShow);
    UpdateWindow(hWnd);

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

	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
	switch(message){
		case WM_DESTROY:{
			PostQuitMessage(0);
			return 0;
		}
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
<p>Fehler von Dev-C++:</p>
<pre><code>C:\DOKUME~1\Tobias\LOKALE~1\Temp\cc6ddaaa.o(.text+0x71) In function `WinMain': 
  [Linker error] undefined reference to `GetStockObject@4' 
 C:\DOKUME~1\Tobias\LOKALE~1\Temp\cc6ddaaa.o(.text+0x71) ld returned 1 exit status
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1048564</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048564</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Sun, 30 Apr 2006 18:45:53 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger: Was ist falsch? on Sun, 30 Apr 2006 18:59:58 GMT]]></title><description><![CDATA[<p>lord_fritte schrieb:</p>
<blockquote>
<p>Also ich weis nicht was hier falsch sein soll:</p>
</blockquote>
<p>Dann solltest du lernen, die Fehlermeldungen zu interpretieren.</p>
<p>Der Linker beschwert sich, dass er GetStockObject nicht findet. Die MSDN Library sagt zu GetStockObject:</p>
<p>Library: Use Gdi32.lib.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048570</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048570</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Sun, 30 Apr 2006 18:59:58 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger: Was ist falsch? on Sun, 30 Apr 2006 19:10:40 GMT]]></title><description><![CDATA[<p>#pragma comment(lib, &quot;gdi32.lib&quot;)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048574</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048574</guid><dc:creator><![CDATA[lolsen]]></dc:creator><pubDate>Sun, 30 Apr 2006 19:10:40 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger: Was ist falsch? on Fri, 15 Sep 2006 07:53:39 GMT]]></title><description><![CDATA[<p>Ich hab das selbe Problem, das hat sich bei mir noch nicht geklärt.<br />
Wenn ich</p>
<pre><code class="language-cpp">#pragma comment(lib, &quot;gdi32.lib&quot;)
</code></pre>
<p>als header in die Datei schreib kommt die selbe fehlermeldung.<br />
Benutze auch Dev-C++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1137757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1137757</guid><dc:creator><![CDATA[circle]]></dc:creator><pubDate>Fri, 15 Sep 2006 07:53:39 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger: Was ist falsch? on Fri, 15 Sep 2006 08:11:34 GMT]]></title><description><![CDATA[<p>wahrscheinlich weil der Compiler (g++) kein pragma kennt.<br />
Du musst in den Projekteinstellungen bei Linker mit angeben, dass gdi32.lib mitgelinkt werden soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1137774</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1137774</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Fri, 15 Sep 2006 08:11:34 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger: Was ist falsch? on Fri, 15 Sep 2006 13:38:37 GMT]]></title><description><![CDATA[<p>Hat sich bei mir geklärt. Man muss bei Dev-C++ einfach ein neues Win 32 Projekt anlegen. Dann funktionierts.<br />
Trotzdem danke, Airdamn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1137977</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1137977</guid><dc:creator><![CDATA[circle]]></dc:creator><pubDate>Fri, 15 Sep 2006 13:38:37 GMT</pubDate></item></channel></rss>