<?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 BUTTON]]></title><description><![CDATA[<p>Hi Leute.</p>
<p>Hoffe ihr könnt mir helfen. Probiere schon seit zwei Tagen herauszufinden wie ich überprüfen kann, ob dieser Button gedrückt wurde:</p>
<pre><code class="language-cpp">void wtButton::create(wtWindow wnd, int x, int y, int wx, int wy, char *title, int id)
{    
    hwnd = CreateWindow(&quot;BUTTON&quot;,title,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,x,y,wx,wy,wnd.getHwnd(),(HMENU)id,wnd.getHinstance(),NULL);
}
</code></pre>
<p>Die Funktion funktioniert einwandfrei. Der Button wird auch angezeigt und ich kann ihn auch drücken. Allerdings wird, wenn man ihn drückt, keine Nachricht verschickt. Ich habe mir alle Nachrichten ausgeben lassen, die das Programm empfängt. Wenn ich den Button an klicke kommt überhaupt keine Nachricht an. Kein WM_COMMAND, kein BN_CLICKED, einfach nix.</p>
<p>Ich weiß nicht woran das liegt.<br />
Hoffe ihr könnt mir helfen.</p>
<p>LG,<br />
Timo</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/128919/problem-mit-button</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 20:24:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/128919.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Dec 2005 13:58:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit BUTTON on Thu, 08 Dec 2005 13:58:41 GMT]]></title><description><![CDATA[<p>Hi Leute.</p>
<p>Hoffe ihr könnt mir helfen. Probiere schon seit zwei Tagen herauszufinden wie ich überprüfen kann, ob dieser Button gedrückt wurde:</p>
<pre><code class="language-cpp">void wtButton::create(wtWindow wnd, int x, int y, int wx, int wy, char *title, int id)
{    
    hwnd = CreateWindow(&quot;BUTTON&quot;,title,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,x,y,wx,wy,wnd.getHwnd(),(HMENU)id,wnd.getHinstance(),NULL);
}
</code></pre>
<p>Die Funktion funktioniert einwandfrei. Der Button wird auch angezeigt und ich kann ihn auch drücken. Allerdings wird, wenn man ihn drückt, keine Nachricht verschickt. Ich habe mir alle Nachrichten ausgeben lassen, die das Programm empfängt. Wenn ich den Button an klicke kommt überhaupt keine Nachricht an. Kein WM_COMMAND, kein BN_CLICKED, einfach nix.</p>
<p>Ich weiß nicht woran das liegt.<br />
Hoffe ihr könnt mir helfen.</p>
<p>LG,<br />
Timo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937360</guid><dc:creator><![CDATA[Dago]]></dc:creator><pubDate>Thu, 08 Dec 2005 13:58:41 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit BUTTON on Thu, 08 Dec 2005 14:21:31 GMT]]></title><description><![CDATA[<p>Hallo Dago,</p>
<p>normalerweiße sollte es so funktionieren:</p>
<pre><code class="language-cpp">switch(Message)
{
    case WM_COMMAND:
        if (LOWORD(wParam) == id)
            {
                bla...
            }
    break;
}
</code></pre>
<p>Hast du auch so eine Routine die dir die Messages übergibt?</p>
<pre><code class="language-cpp">while(GetMessage(&amp;Msg, NULL, 0, 0))
{
    TranslateMessage(&amp;Msg);
    DispatchMessage(&amp;Msg);
}
return Msg.wParam;
</code></pre>
<p>Gruß<br />
yogle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937387</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Thu, 08 Dec 2005 14:21:31 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit BUTTON on Thu, 08 Dec 2005 14:23:24 GMT]]></title><description><![CDATA[<p>du musst ne WindowPorzedur da rein packen...</p>
<pre><code class="language-cpp">LRESULT CALLBACK wtButton::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   case WM_COMMAND:
      {
         if (lParam == (LPARAM)hwnd)
         {
            if (HIWORD(wParam) == BN_CLICKED)
               SendMessage(hWnd, WM_CLOSE, 0, 0);
         }
         return 0;
   }
   return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/937393</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937393</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Thu, 08 Dec 2005 14:23:24 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit BUTTON on Thu, 08 Dec 2005 14:37:14 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Ich hab jetzt herausgefunden, dass der Button tatsächlich eine WM_COMMAND Message schickt. Ich hab bislang probiert sie so abzufangen:</p>
<pre><code class="language-cpp">if (GetMessage(&amp;messages, NULL, 0, 0))
        {
            TranslateMessage(&amp;messages);

            if (messages.message == WM_COMMAND) MessageBox(NULL,&quot;Kam was an&quot;,&quot;...&quot;,MB_OK);
            else;

            DispatchMessage(&amp;messages);
            return true;
        }
</code></pre>
<p>Das hat allerdings nicht geklappt. Nur in der WNDPROC-Funktion konnte ich die Nachricht abfangen.<br />
Komischerweise funktioniert diese Abfrage aber, wenn zum Beispiel ein Menü angeklickt wurde.</p>
<p>@ (D)Evil:<br />
Das habe ich schon probiert. Aber der Compiler (benutze Dev-C++) meckert, dass ich die WindowPorzedur nicht in eine Klasse einbinden kann. Hab sie deshalb außerhalb der Klasse so laufen:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                
    {
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:                     
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>Wenn ich hier das hier hinzufüge, funktioniert es auch wenn der Button geklickt wurde:</p>
<pre><code class="language-cpp">case WM_COMMAND:
    MessageBox(NULL,&quot;Hier funktionierts&quot;,&quot;...&quot;,MB_OK);
    break;
</code></pre>
<p>Aber warum funktioniert die Variante oben nicht?</p>
<p>EDIT:<br />
Nachtrag: WM_MOVE oder WM_SIZE kann ich zum Beispiel über meine Variante (ganz oben) auch nicht abfangen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937404</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937404</guid><dc:creator><![CDATA[Dago]]></dc:creator><pubDate>Thu, 08 Dec 2005 14:37:14 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit BUTTON on Thu, 08 Dec 2005 15:52:10 GMT]]></title><description><![CDATA[<p>@ (D)Evil:<br />
Wenn ich es so mach, wie du gemeint hast bekomme ich für diese Zeile:</p>
<pre><code class="language-cpp">wincl.lpfnWndProc = WindowProcedure;
</code></pre>
<p>Diese Fehlermeldung:</p>
<pre><code>argument of type `LRESULT (wtWindow::)(HWND__*, UINT, WPARAM, LPARAM)' does not match `LRESULT (*)(HWND__*, UINT, WPARAM, LPARAM)'
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/937464</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937464</guid><dc:creator><![CDATA[Dago]]></dc:creator><pubDate>Thu, 08 Dec 2005 15:52:10 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit BUTTON on Fri, 09 Dec 2005 06:19:44 GMT]]></title><description><![CDATA[<p>Vielleicht hilft dir <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39356.html" rel="nofollow">das hier</a>?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/937823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937823</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Fri, 09 Dec 2005 06:19:44 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit BUTTON on Fri, 09 Dec 2005 19:24:14 GMT]]></title><description><![CDATA[<p>Hallo Dago,</p>
<p>also ich programmiere auch mit Dev-Cpp und bei mir läuft dieser<br />
Code einwandfrei.<br />
Einfach mal ein neues leeres Projekt erstellen und den Code so<br />
wie er dasteht reinkopieren. Müsste funktionieren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

HWND hwnd;
HWND buttonTest;

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        // Button erstellen
        case WM_CREATE:
            buttonTest = CreateWindowEx (WS_EX_WINDOWEDGE,&quot;button&quot;,&quot;Test&quot;,WS_CHILD | WS_VISIBLE,
							            85, 70, 80, 30, hwnd, (HMENU)1, 
							            (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);    
        break;

        // Kommando empfangen
        case WM_COMMAND:
             if (LOWORD(wParam) == 1)    
             {
                 MessageBox(NULL,&quot;Button wurde gedrückt!&quot;,&quot;Hallo&quot;,MB_OK);
             }
        break;    

        // X-Button 
        case WM_CLOSE:
            ExitProcess(0);
        break;

        default:
        return DefWindowProc(hwnd, Message, wParam, lParam);
    }
}        

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    static HINSTANCE g_hInst = NULL;
    static char g_szClassName[] = &quot;MyWindowClass&quot;;

    WNDCLASSEX WndClass; 
    g_hInst = hInstance;
    MSG Msg;

    WndClass.cbSize        = sizeof(WNDCLASSEX);
    WndClass.style         = 0;
    WndClass.lpfnWndProc   = WndProc;
    WndClass.cbClsExtra    = 0;
    WndClass.cbWndExtra    = 0;
    WndClass.hInstance     = g_hInst;
    WndClass.hIcon         = (HICON)LoadIcon(NULL,IDI_APPLICATION);
    WndClass.hCursor       = LoadCursor(NULL,IDC_ARROW);
    WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
    WndClass.lpszMenuName  = NULL;
    WndClass.lpszClassName = g_szClassName;
    WndClass.hIconSm       = WndClass.hIcon;

    RegisterClassEx(&amp;WndClass);

    hwnd = CreateWindowEx(
                          WS_EX_CLIENTEDGE,
                          g_szClassName,
                          &quot;Testprogramm&quot;,
                          DS_MODALFRAME | DS_3DLOOK | DS_CENTER | 
                             WS_MINIMIZEBOX | WS_SYSMENU | WS_POPUP | 
                             WS_CAPTION | WS_EX_CLIENTEDGE,
                          500,  
                          350,  
                          250, 
                          200,
                          NULL, 
                          NULL, 
                          g_hInst, 
                          NULL );

    ShowWindow(hwnd,SW_SHOWNORMAL);

    while(GetMessage(&amp;Msg, NULL, 0, 0))
    {
       TranslateMessage(&amp;Msg);
       DispatchMessage(&amp;Msg);
    }
    return Msg.wParam;
}
</code></pre>
<p>Viel Spaß noch mit dem programmieren. <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="🙂"
    /><br />
Gruß yogle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/938424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/938424</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Fri, 09 Dec 2005 19:24:14 GMT</pubDate></item></channel></rss>