<?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[[gelöst] Programm beendet sich gleich wieder ...]]></title><description><![CDATA[<p>Servus,</p>
<p>kann mir bitte jemand sagen warum dieses Programm sich sofort wieder beendet ?<br />
Rückgabewert ist 0, also keine Syntaxfehler.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

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

char szAppName[ ] = &quot;IDE&quot;;
HINSTANCE hInstance ;
HINSTANCE hSciLexer ;
#define ID_SCINTILLA    1

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     LPSTR lpszArgument, int nCmdShow)
{
    HWND hWnd ;
    MSG nMsg ;
    WNDCLASSEX WndClass ;

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

    if (!RegisterClassEx (&amp;WndClass))
        {
            MessageBox(hWnd,
            &quot;The window class could not be registered.&quot;,
            szAppName, MB_OK | MB_ICONERROR) ;
            return 0 ;
        }

    hWnd = CreateWindowEx (0, szAppName, szAppName,
           WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
           CW_USEDEFAULT, CW_USEDEFAULT, 644, 475,
           NULL, NULL, hInstance, NULL) ;

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

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

    return nMsg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HWND      hWndEdit ;

    hSciLexer = LoadLibrary(&quot;SciLexer.DLL&quot;) ;
            if (hSciLexer == NULL)
            {
                MessageBox(hWnd,
                &quot;The Scintilla DLL could not be loaded.&quot;,
                &quot;Error loading Scintilla&quot;,
                MB_OK | MB_ICONERROR) ;
                return -1 ;
            }

    switch (message)
    {
        case WM_CREATE :

            hWndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, &quot;Scintilla&quot;, &quot;&quot;,
                                      WS_CHILD | WS_VISIBLE | WS_TABSTOP,
		                              10, 10, 500, 400,
		                              hWnd,(HMENU) ID_SCINTILLA, hInstance, NULL) ;
            return 0 ;

        case WM_DESTROY :

            PostQuitMessage (0) ;
            return 0 ;
    }

    return DefWindowProc (hWnd, message, wParam, lParam) ;
}
</code></pre>
<p>Seid bitte nicht zu streng mit mir, ich bin noch Anfänger ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Vielen Dank für die Aufmerksamkeit.</p>
<p>Gruß<br />
Greenhorn</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/208895/gelöst-programm-beendet-sich-gleich-wieder</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 13:57:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/208895.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Mar 2008 10:46:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [gelöst] Programm beendet sich gleich wieder ... on Mon, 24 Mar 2008 13:32:26 GMT]]></title><description><![CDATA[<p>Servus,</p>
<p>kann mir bitte jemand sagen warum dieses Programm sich sofort wieder beendet ?<br />
Rückgabewert ist 0, also keine Syntaxfehler.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

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

char szAppName[ ] = &quot;IDE&quot;;
HINSTANCE hInstance ;
HINSTANCE hSciLexer ;
#define ID_SCINTILLA    1

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     LPSTR lpszArgument, int nCmdShow)
{
    HWND hWnd ;
    MSG nMsg ;
    WNDCLASSEX WndClass ;

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

    if (!RegisterClassEx (&amp;WndClass))
        {
            MessageBox(hWnd,
            &quot;The window class could not be registered.&quot;,
            szAppName, MB_OK | MB_ICONERROR) ;
            return 0 ;
        }

    hWnd = CreateWindowEx (0, szAppName, szAppName,
           WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
           CW_USEDEFAULT, CW_USEDEFAULT, 644, 475,
           NULL, NULL, hInstance, NULL) ;

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

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

    return nMsg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HWND      hWndEdit ;

    hSciLexer = LoadLibrary(&quot;SciLexer.DLL&quot;) ;
            if (hSciLexer == NULL)
            {
                MessageBox(hWnd,
                &quot;The Scintilla DLL could not be loaded.&quot;,
                &quot;Error loading Scintilla&quot;,
                MB_OK | MB_ICONERROR) ;
                return -1 ;
            }

    switch (message)
    {
        case WM_CREATE :

            hWndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, &quot;Scintilla&quot;, &quot;&quot;,
                                      WS_CHILD | WS_VISIBLE | WS_TABSTOP,
		                              10, 10, 500, 400,
		                              hWnd,(HMENU) ID_SCINTILLA, hInstance, NULL) ;
            return 0 ;

        case WM_DESTROY :

            PostQuitMessage (0) ;
            return 0 ;
    }

    return DefWindowProc (hWnd, message, wParam, lParam) ;
}
</code></pre>
<p>Seid bitte nicht zu streng mit mir, ich bin noch Anfänger ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Vielen Dank für die Aufmerksamkeit.</p>
<p>Gruß<br />
Greenhorn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1479471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1479471</guid><dc:creator><![CDATA[C++Greenhorn 0]]></dc:creator><pubDate>Mon, 24 Mar 2008 13:32:26 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Programm beendet sich gleich wieder ... on Mon, 24 Mar 2008 11:45:05 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">hSciLexer = LoadLibrary(&quot;SciLexer.DLL&quot;) ;
            if (hSciLexer == NULL)
            {
                MessageBox(hWnd,
                &quot;The Scintilla DLL could not be loaded.&quot;,
                &quot;Error loading Scintilla&quot;,
                MB_OK | MB_ICONERROR) ;
                return -1 ;
            }
</code></pre>
<p>Evtl. liegts an dieser stelle hier im code, dass wenn hier nämlich das return<br />
-1, kommt kein return DefWindowProc mehr kommen kann. Sprich er findet deine DLL nicht, du solltest das auch besser in die WM_CREATE paacken sonst wird das nämlich bei jedem Durchlauf deiner WindowProc ausgeführt. Obwohl wenn das fehlschlägt eigentlich ne Messagebox kommen müsste?<br />
Naja packs einfach mal in die WM_CREATE.</p>
<p>Gruß Tobi.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1479514</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1479514</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Mon, 24 Mar 2008 11:45:05 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Programm beendet sich gleich wieder ... on Mon, 24 Mar 2008 12:32:02 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich habe gerade mit deinem Quellcode ein bissle rumgespielt und bin zum ergebnis gekommen das dein Fenster nicht regisriert werden konnte:</p>
<pre><code class="language-cpp">if (!RegisterClassEx (&amp;WndClass))
        {
            MessageBox(hWnd,
            &quot;The window class could not be registered.&quot;,
            szAppName, MB_OK | MB_ICONERROR) ;
            return 0 ;
        }
</code></pre>
<p>Dein Programm hüpft hier in den If-Teil hinein zeigt aber die MessageBox ned an, da &quot;hWnd&quot; ja keine gültiger Handle zu einem Fenster ist.<br />
Würdeste ja erst hier zuweisen:</p>
<pre><code class="language-cpp">hWnd = CreateWindowEx (0, szAppName, szAppName,
           WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
           CW_USEDEFAULT, CW_USEDEFAULT, 644, 475,
           NULL, NULL, hInstance, NULL) ;
</code></pre>
<p>Also einfach da mal &quot;NULL&quot; angeben und schon müsste die MessageBox erscheinen.</p>
<p>Was aber jetzt an deinem WndClass falsch ist ka sorry.</p>
<p>Ich hab mal GetLastError() ausgewertet:<br />
Error Nr: 87 Text: Falscher Parameter</p>
<p>MFG PinguGroup</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1479536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1479536</guid><dc:creator><![CDATA[PinguGroup]]></dc:creator><pubDate>Mon, 24 Mar 2008 12:32:02 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Programm beendet sich gleich wieder ... on Mon, 24 Mar 2008 12:49:22 GMT]]></title><description><![CDATA[<p>Danke für den Tip, aber das hatte ich zuerst auch so, mit dem gleichen Ergebnis.<br />
Selbst wenn ich den WM_CREATE-Zweig leer lasse passiert das Gleiche ...</p>
<p>... oO</p>
<p>sehe gerade die zweite Antwort ...</p>
<p>Ja, das habe ich mir schon gedacht, das es an der WndClass liegt, aber warum ... ?<br />
Sehr merkwürdig *frust*</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1479543</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1479543</guid><dc:creator><![CDATA[C++Greenhorn 0]]></dc:creator><pubDate>Mon, 24 Mar 2008 12:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Programm beendet sich gleich wieder ... on Mon, 24 Mar 2008 12:51:45 GMT]]></title><description><![CDATA[<p>Tatsache, mit der NULL klappt's auch mit dem Nachbarn, aber leider das falsche Fenster <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> <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>Ich werde die Nase noch mal in den Petzold stecken ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1479545</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1479545</guid><dc:creator><![CDATA[C++Greenhorn 0]]></dc:creator><pubDate>Mon, 24 Mar 2008 12:51:45 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Programm beendet sich gleich wieder ... on Mon, 24 Mar 2008 13:12:57 GMT]]></title><description><![CDATA[<p>Also, wenn ich anstatt WNDCLASSEX und RegisterClassEx nun WNDCLASS und RegisterClass nehme, dann geht alles seinen Gang. <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>Liegt es vielleicht an meiner IDE ?<br />
Ich benutze Code::Blocks v8.0.2 ...</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1479562</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1479562</guid><dc:creator><![CDATA[C++Greenhorn 0]]></dc:creator><pubDate>Mon, 24 Mar 2008 13:12:57 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] Programm beendet sich gleich wieder ... on Mon, 24 Mar 2008 13:31:08 GMT]]></title><description><![CDATA[<p>Ahhh, ich hab's.</p>
<p>Bei WNDCLASSEX fehlte der Parameter</p>
<pre><code class="language-cpp">WndClass.cbSize = sizeof (WNDCLASSEX);
</code></pre>
<p>Tja, der gute Petzold ist ja auch schon etwas in die Jahre gekommen ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Die ganzen *Ex Funktionen sind mir neu, oder besser gesagt nicht im Buch - jedenfalls nicht alle -</p>
<p>Jetzt läuft's, vielen Dank noch einmal an euch beiden für die Hilfe !!!</p>
<p>Gruß<br />
C++Greenhorn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1479575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1479575</guid><dc:creator><![CDATA[C++Greenhorn 0]]></dc:creator><pubDate>Mon, 24 Mar 2008 13:31:08 GMT</pubDate></item></channel></rss>