<?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 ausgabe(Anfänger)]]></title><description><![CDATA[<p>Also ich mache gerade das tutorial von Henno durch(<a href="http://www.win-api.de" rel="nofollow">www.win-api.de</a>).<br />
Nun wollte ich (bin bei Lektion 11) mal was selber schreiben. Leider klappt<br />
es nicht. <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="😞"
    /><br />
Das Program soll mir eine zahl ausgeben die wenn man die linke Maus taste<br />
drück um 1 erhöht wir. Das erste mal kommt 1 wenn man nochmal klickt passiert<br />
nichts mehr.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

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

const char szAppName[] = &quot;Test&quot;;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
    HWND     hWnd;
    MSG      msg;
    WNDCLASS wc;

    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;Test&quot;,
                        WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT,  
                        CW_USEDEFAULT,  
                        CW_USEDEFAULT,  
                        CW_USEDEFAULT,  
                        NULL,
                        NULL,
                        hInstance,
                        NULL);

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

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

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

int zahl = 0;
char text[100];
int lange;
    switch(message)
    {

                case WM_LBUTTONDOWN:
           {

            zahl++;
          lange = wsprintf(text, &quot;%i&quot;, zahl);

             HDC hDC = GetDC(hWnd);
             TextOut(hDC, 50, 50, text, lange);
             ReleaseDC(hWnd, hDC);

               return 0;

           }

        case WM_DESTROY:
           {
               PostQuitMessage(0);
               return 0;
           }
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/141839/problem-mit-ausgabe-anfänger</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Jul 2026 12:19:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/141839.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Mar 2006 15:12:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit ausgabe(Anfänger) on Sat, 25 Mar 2006 15:12:00 GMT]]></title><description><![CDATA[<p>Also ich mache gerade das tutorial von Henno durch(<a href="http://www.win-api.de" rel="nofollow">www.win-api.de</a>).<br />
Nun wollte ich (bin bei Lektion 11) mal was selber schreiben. Leider klappt<br />
es nicht. <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="😞"
    /><br />
Das Program soll mir eine zahl ausgeben die wenn man die linke Maus taste<br />
drück um 1 erhöht wir. Das erste mal kommt 1 wenn man nochmal klickt passiert<br />
nichts mehr.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

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

const char szAppName[] = &quot;Test&quot;;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
    HWND     hWnd;
    MSG      msg;
    WNDCLASS wc;

    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;Test&quot;,
                        WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT,  
                        CW_USEDEFAULT,  
                        CW_USEDEFAULT,  
                        CW_USEDEFAULT,  
                        NULL,
                        NULL,
                        hInstance,
                        NULL);

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

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

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

int zahl = 0;
char text[100];
int lange;
    switch(message)
    {

                case WM_LBUTTONDOWN:
           {

            zahl++;
          lange = wsprintf(text, &quot;%i&quot;, zahl);

             HDC hDC = GetDC(hWnd);
             TextOut(hDC, 50, 50, text, lange);
             ReleaseDC(hWnd, hDC);

               return 0;

           }

        case WM_DESTROY:
           {
               PostQuitMessage(0);
               return 0;
           }
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1023754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1023754</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Sat, 25 Mar 2006 15:12:00 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit ausgabe(Anfänger) on Sat, 25 Mar 2006 15:58:39 GMT]]></title><description><![CDATA[<p>Probiere mal statt:</p>
<pre><code class="language-cpp">HDC hDC = GetDC(hWnd);
TextOut(hDC, 50, 50, text, lange);
ReleaseDC(hWnd, hDC);
</code></pre>
<p>das hier:</p>
<pre><code class="language-cpp">MessageBox (hWnd, lange, &quot;Zahl&quot;, MB_ICONINFORMATION);
</code></pre>
<p>Wenns klappt dann liegt es daran, dass der Text nicht richitg überschrieben wird, sondern einfach nur drunter gelegt wird.</p>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1023783</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1023783</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Sat, 25 Mar 2006 15:58:39 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit ausgabe(Anfänger) on Sat, 25 Mar 2006 16:04:56 GMT]]></title><description><![CDATA[<p>Also lange wollte ich nicht ausgeben und die zahl direkt klappt auch nicht(also einen int). Mit dem char bleibt es immer 1. <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/1023787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1023787</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Sat, 25 Mar 2006 16:04:56 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit ausgabe(Anfänger) on Sat, 25 Mar 2006 16:09:00 GMT]]></title><description><![CDATA[<p>Mein Fehler. Ersetze lange durch text.</p>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1023788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1023788</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Sat, 25 Mar 2006 16:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit ausgabe(Anfänger) on Sat, 25 Mar 2006 16:07:41 GMT]]></title><description><![CDATA[<p>Wenn ich das so mache:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

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

const char szAppName[] = &quot;Test&quot;;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
    HWND     hWnd;
    MSG      msg;
    WNDCLASS wc;

    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;Test&quot;,
                        WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT,
                        CW_USEDEFAULT,
                        CW_USEDEFAULT,
                        CW_USEDEFAULT,
                        NULL,
                        NULL,
                        hInstance,
                        NULL);

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

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

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

int zahl = 0;
char text[100];
char text2[23];
int lange;
    switch(message)
    {

                case WM_LBUTTONDOWN:
           {

            zahl++;
          lange = wsprintf(text, &quot;%i&quot;, zahl);

          MessageBox (hWnd,  text, &quot;Zahl&quot;, MB_ICONINFORMATION);
          zahl++;
          lange = wsprintf(text2, &quot;%i&quot;, zahl);
          MessageBox (hWnd,  text2, &quot;Zahl&quot;, MB_ICONINFORMATION);
             /*HDC hDC = GetDC(hWnd);
             TextOut(hDC, 50, 50, text, lange);
             ReleaseDC(hWnd, hDC);*/

               return 0;
       }
   case WM_LBUTTONUP:
      {

          return 0;
      }

        case WM_DESTROY:
           {
               PostQuitMessage(0);
               return 0;
           }
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
<p>Klappt es inderekt also erste box eins die zweite 2. Allerdings bleiben sie dann auch so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1023791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1023791</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Sat, 25 Mar 2006 16:07:41 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit ausgabe(Anfänger) on Sat, 25 Mar 2006 16:11:11 GMT]]></title><description><![CDATA[<p>Mache text und text2 static und staune <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>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1023794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1023794</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Sat, 25 Mar 2006 16:11:11 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit ausgabe(Anfänger) on Sat, 25 Mar 2006 16:14:09 GMT]]></title><description><![CDATA[<p>Danke jetzt klapps. Ich hab das jetzt mit static gemacht. Alerdings musste ich dann auch die int static machen.</p>
<p>Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1023796</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1023796</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Sat, 25 Mar 2006 16:14:09 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit ausgabe(Anfänger) on Sat, 25 Mar 2006 16:56:45 GMT]]></title><description><![CDATA[<p>Es reicht wenn Du die &quot;zahl&quot; static machst... oder Du gibst dem Fenster eine Struktur mit, wo Du Fenster-Spezifische Dinge ablegst.<br />
Siehe: Set/GetWindowLong(Ptr) mit GWLP_USERDATA<br />
dann kannst Du auf static verzichten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1023820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1023820</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 25 Mar 2006 16:56:45 GMT</pubDate></item></channel></rss>