<?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[Einer meiner Button wird nicht angezeigt...]]></title><description><![CDATA[<p>hi</p>
<p>ich suche schon länger den Fehler in meinem Code, welcher bewirkt das einer der drei Buttons nicht angezeigt wird. Der Compiler gibt aber keinen Fehler aus.<br />
Wahrscheinlich habe ich was übersehen. Vielleicht kann mir ja jemand helfen...</p>
<p>Erstmal der Code...<br />
(durch die vielen Schnipsel, die ich aus der Not/Verzweifelung hinein kopiert habe, wirkt das ein oder andere vielleicht ein bisschen komisch oder überflüssig)</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

/*  Declare Windows procedure  */

#define i   1
#define j   2
#define k   3

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

/*  Make the class name into a global variable  */
char szAppName[ ] = &quot;CodeBlocksWindowsApp&quot;;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASS     wndclass ;

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

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClass (&amp;wndclass))
     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
          MessageBox (NULL, TEXT (&quot;Programm arbeitet mit Unicode und setzt Windows NT voraus!&quot;), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

    /* The class is registered, let's create the program*/
    hwnd = CreateWindow (szAppName, TEXT (&quot;Varianten von Kontrollelementen&quot;),
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          NULL, NULL, hInstance, NULL) ;

    /* Make the window visible on the screen */
    ShowWindow (hwnd, iCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HWND hwndButton;
    static HWND hwndbutton;
    static HWND hwndbuttonen;
    static RECT rect;

    static int   cxChar, cyChar ;
    HDC       hdc ;
    PAINTSTRUCT  ps ;

    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
            cxChar = LOWORD (GetDialogBaseUnits ()) ;
            cyChar = HIWORD (GetDialogBaseUnits ()) ;

            //der folgende ist der Problembutton, der nicht angezeigt wird
            hwndButton = CreateWindow (TEXT(&quot;button1&quot;),
                         &quot;Butoon1&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                         cxChar, cyChar * (1 + 2* k),
                         21 * cxChar, 8 * cyChar / 3,hwnd,(HMENU) k,
                         ((LPCREATESTRUCT) lParam)-&gt;hInstance, NULL);

            //der folgende wird angezeigt
            hwndbutton = CreateWindow ( TEXT(&quot;button&quot;), 
                                   &quot;DEFPUSHBUTTON1&quot;,
                                   WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                                   cxChar, cyChar * (1 + 2 * i),
                                   20 * cxChar, 7 * cyChar / 4,
                                   hwnd, (HMENU) i,
                                   ((LPCREATESTRUCT) lParam)-&gt;hInstance, NULL) ;

            //der folgende wird angezeigt
            hwndbuttonen = CreateWindow ( TEXT(&quot;button&quot;), 
                                   &quot;DEFPUSHBUTTON2&quot;,
                                   WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                                   cxChar, cyChar * (1 + 2 * j),
                                   20 * cxChar, 7 * cyChar / 4,
                                   hwnd, (HMENU) j,
                                   ((LPCREATESTRUCT) lParam)-&gt;hInstance, NULL) ;

            return 0;

        case WM_SIZE :
          //rect.left   = 24 * cxChar ;
          //rect.top    =  2 * cyChar ;
          //rect.right  = LOWORD (lParam) ;
          //rect.bottom = HIWORD (lParam) ;
          return 0 ;

        case WM_PAINT :
          InvalidateRect (hwnd, &amp;rect, TRUE) ;

          hdc = BeginPaint (hwnd, &amp;ps) ;
          //Paint
          EndPaint (hwnd, &amp;ps) ;
          return 0 ;

        case WM_DRAWITEM :
        case WM_COMMAND :

          hdc = GetDC (hwnd) ;
          ReleaseDC (hwnd, hdc) ;
          InvalidateRect (hwnd, &amp;rect, TRUE) ;
          break ;

        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>Vielleicht kann mir ja jemand helfen...<br />
und vielleicht hat ja auch jemand Verbesserungsvorschläge</p>
<p>Danke an alle, die zu einer Lösung beitragen... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/181866/einer-meiner-button-wird-nicht-angezeigt</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 20:19:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/181866.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 May 2007 10:29:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Einer meiner Button wird nicht angezeigt... on Fri, 18 May 2007 10:29:34 GMT]]></title><description><![CDATA[<p>hi</p>
<p>ich suche schon länger den Fehler in meinem Code, welcher bewirkt das einer der drei Buttons nicht angezeigt wird. Der Compiler gibt aber keinen Fehler aus.<br />
Wahrscheinlich habe ich was übersehen. Vielleicht kann mir ja jemand helfen...</p>
<p>Erstmal der Code...<br />
(durch die vielen Schnipsel, die ich aus der Not/Verzweifelung hinein kopiert habe, wirkt das ein oder andere vielleicht ein bisschen komisch oder überflüssig)</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

/*  Declare Windows procedure  */

#define i   1
#define j   2
#define k   3

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

/*  Make the class name into a global variable  */
char szAppName[ ] = &quot;CodeBlocksWindowsApp&quot;;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASS     wndclass ;

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

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClass (&amp;wndclass))
     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
          MessageBox (NULL, TEXT (&quot;Programm arbeitet mit Unicode und setzt Windows NT voraus!&quot;), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

    /* The class is registered, let's create the program*/
    hwnd = CreateWindow (szAppName, TEXT (&quot;Varianten von Kontrollelementen&quot;),
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          NULL, NULL, hInstance, NULL) ;

    /* Make the window visible on the screen */
    ShowWindow (hwnd, iCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HWND hwndButton;
    static HWND hwndbutton;
    static HWND hwndbuttonen;
    static RECT rect;

    static int   cxChar, cyChar ;
    HDC       hdc ;
    PAINTSTRUCT  ps ;

    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
            cxChar = LOWORD (GetDialogBaseUnits ()) ;
            cyChar = HIWORD (GetDialogBaseUnits ()) ;

            //der folgende ist der Problembutton, der nicht angezeigt wird
            hwndButton = CreateWindow (TEXT(&quot;button1&quot;),
                         &quot;Butoon1&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                         cxChar, cyChar * (1 + 2* k),
                         21 * cxChar, 8 * cyChar / 3,hwnd,(HMENU) k,
                         ((LPCREATESTRUCT) lParam)-&gt;hInstance, NULL);

            //der folgende wird angezeigt
            hwndbutton = CreateWindow ( TEXT(&quot;button&quot;), 
                                   &quot;DEFPUSHBUTTON1&quot;,
                                   WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                                   cxChar, cyChar * (1 + 2 * i),
                                   20 * cxChar, 7 * cyChar / 4,
                                   hwnd, (HMENU) i,
                                   ((LPCREATESTRUCT) lParam)-&gt;hInstance, NULL) ;

            //der folgende wird angezeigt
            hwndbuttonen = CreateWindow ( TEXT(&quot;button&quot;), 
                                   &quot;DEFPUSHBUTTON2&quot;,
                                   WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                                   cxChar, cyChar * (1 + 2 * j),
                                   20 * cxChar, 7 * cyChar / 4,
                                   hwnd, (HMENU) j,
                                   ((LPCREATESTRUCT) lParam)-&gt;hInstance, NULL) ;

            return 0;

        case WM_SIZE :
          //rect.left   = 24 * cxChar ;
          //rect.top    =  2 * cyChar ;
          //rect.right  = LOWORD (lParam) ;
          //rect.bottom = HIWORD (lParam) ;
          return 0 ;

        case WM_PAINT :
          InvalidateRect (hwnd, &amp;rect, TRUE) ;

          hdc = BeginPaint (hwnd, &amp;ps) ;
          //Paint
          EndPaint (hwnd, &amp;ps) ;
          return 0 ;

        case WM_DRAWITEM :
        case WM_COMMAND :

          hdc = GetDC (hwnd) ;
          ReleaseDC (hwnd, hdc) ;
          InvalidateRect (hwnd, &amp;rect, TRUE) ;
          break ;

        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>Vielleicht kann mir ja jemand helfen...<br />
und vielleicht hat ja auch jemand Verbesserungsvorschläge</p>
<p>Danke an alle, die zu einer Lösung beitragen... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287282</guid><dc:creator><![CDATA[helpme]]></dc:creator><pubDate>Fri, 18 May 2007 10:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to Einer meiner Button wird nicht angezeigt... on Fri, 18 May 2007 10:41:50 GMT]]></title><description><![CDATA[<p>Beim Problembutton hast du dich verschrieben.</p>
<pre><code>hwndButton = CreateWindow (TEXT(&quot;button1&quot;),
                         &quot;BUTTON&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                         cxChar, cyChar * (1 + 2* k),
                         21 * cxChar, 8 * cyChar / 3,hwnd,(HMENU) k,
                         ((LPCREATESTRUCT) lParam)-&gt;hInstance, NULL);
</code></pre>
<p>Es muss BUTTON heißen und nicht Butoon.</p>
<p>MFG Thorben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287292</guid><dc:creator><![CDATA[Thorben]]></dc:creator><pubDate>Fri, 18 May 2007 10:41:50 GMT</pubDate></item><item><title><![CDATA[Reply to Einer meiner Button wird nicht angezeigt... on Fri, 18 May 2007 10:59:48 GMT]]></title><description><![CDATA[<p>danke für deine antwort</p>
<p>aber es lag nicht an dem &quot;Butoon1&quot;, weil es nur die Beschriftung des Buttons darstellt.</p>
<p>Der Fehler war das es (TEXT(&quot;button&quot;) heißen muss und nicht (TEXT(&quot;button1&quot;)</p>
<p>Aber trotzdem danke, weil mich deine Antwort darauf aufmerksam gemacht hat und ich ohne die Antwort wahrscheinlich noch Jahre gesucht hätte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287301</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287301</guid><dc:creator><![CDATA[helpme]]></dc:creator><pubDate>Fri, 18 May 2007 10:59:48 GMT</pubDate></item></channel></rss>