<?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[LRESULT -&amp;gt; Char[] bzw. long]]></title><description><![CDATA[<p>Hi,</p>
<p>also ich habe folgendes Programm:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;windef.h&gt;
#include &lt;winuser.h&gt;

#define edit1     1
#define button1   2
#define button2   3

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

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static char szAppName[] = &quot;Name&quot; ;
     HWND        hwnd ;
     MSG         msg ;
     WNDCLASSEX  wndclass ;

     wndclass.cbSize        = sizeof (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 ;
     wndclass.hIconSm       = LoadIcon (NULL, IDI_APPLICATION) ;

     RegisterClassEx (&amp;wndclass) ;

     hwnd = CreateWindow (szAppName, &quot;WinAPI&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) ;
          }
     return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
        static HWND hwndedit1, hwndbutton1, hwndbutton2; 
        LRESULT a = 1, b = 2;
        switch (iMsg)
        {
               case WM_CREATE :
			   hwndedit1 = CreateWindowEx(WS_EX_CLIENTEDGE ,&quot;edit&quot;, NULL,WS_CHILD | WS_VISIBLE | ES_LEFT,
				        0, 0, 150, 20, hwnd, (HMENU) edit1,
				        ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ;
	           SendMessage(hwndedit1, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
	           SendMessage(hwndedit1, WM_SETTEXT, 0, (long)&quot;1&quot;);

			   hwndbutton1 = CreateWindow (&quot;button&quot;, &quot;Bitte Klicken&quot;,
   	                     WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
				         0, 40, 150, 30, hwnd, (HMENU) button1,
				         ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ; //Button &quot;=&quot; bzw. Berechne
               SendMessage(hwndbutton1, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);

               hwndbutton2 = CreateWindow (&quot;button&quot;, &quot;Open MessageBox&quot;, 
                          WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_VCENTER,
                          10, 100, 500, 30, hwnd, (HMENU) button2,
                          ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL);
               SendMessage(hwndbutton2, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);

			   return 0 ;

		       case WM_COMMAND:
			   switch (HIWORD(wParam))//Aktionsauswahl
			   {
			          case BN_CLICKED://Button gedrückt ?
				      switch(LOWORD(wParam))//Welcher ?
				      {
                           case button1:
					       SendMessage(hwndedit1,WM_SETTEXT,0,(long)&quot;Der Button wurde gedrückt&quot;);
					       break;

					       case button2:

                           if (SendMessage(hwndedit1, WM_GETTEXT, 0, 0) == (long)&quot;1&quot;)                           
                           SendMessage (hwndedit1, WM_SETTEXT, 0, (long)&quot;2&quot;);
                           else 
                           if (SendMessage(hwndedit1, WM_GETTEXT, 0, 0) == (long)&quot;2&quot;)
                           SendMessage(hwndedit1, WM_SETTEXT, 0, (long)&quot;1&quot;);
                           else
                           MessageBox(hwnd,&quot;gvzgd&quot;,&quot;hbcfe&quot;,0);

                           break;
				       }
				       break;
			  }
			  return 0;

			  case WM_DESTROY :
				  PostQuitMessage (0) ;
				  return 0 ;
	 }
     return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
</code></pre>
<p>Also, das Programm soll eigentlich Wenn man den unteren Button drückt die 1 in der Editbox zu einer 2 machen oder andersrum.</p>
<p>Ich denke der Fehler liegt hier drin:</p>
<pre><code class="language-cpp">if (SendMessage(hwndedit1, WM_GETTEXT, 0, 0) ==(long)&quot;1&quot;) [/code]
</code></pre>
<p>aber ich hab keine ahnung wie ich ihn beheben kann.</p>
<p>Kann mir jemand helfen? <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>Schonmal danke im voraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/127712/lresult-gt-char-bzw-long</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 15:05:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/127712.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 26 Nov 2005 17:14:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to LRESULT -&amp;gt; Char[] bzw. long on Sat, 26 Nov 2005 17:14:49 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>also ich habe folgendes Programm:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;windef.h&gt;
#include &lt;winuser.h&gt;

#define edit1     1
#define button1   2
#define button2   3

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

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static char szAppName[] = &quot;Name&quot; ;
     HWND        hwnd ;
     MSG         msg ;
     WNDCLASSEX  wndclass ;

     wndclass.cbSize        = sizeof (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 ;
     wndclass.hIconSm       = LoadIcon (NULL, IDI_APPLICATION) ;

     RegisterClassEx (&amp;wndclass) ;

     hwnd = CreateWindow (szAppName, &quot;WinAPI&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) ;
          }
     return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
        static HWND hwndedit1, hwndbutton1, hwndbutton2; 
        LRESULT a = 1, b = 2;
        switch (iMsg)
        {
               case WM_CREATE :
			   hwndedit1 = CreateWindowEx(WS_EX_CLIENTEDGE ,&quot;edit&quot;, NULL,WS_CHILD | WS_VISIBLE | ES_LEFT,
				        0, 0, 150, 20, hwnd, (HMENU) edit1,
				        ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ;
	           SendMessage(hwndedit1, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
	           SendMessage(hwndedit1, WM_SETTEXT, 0, (long)&quot;1&quot;);

			   hwndbutton1 = CreateWindow (&quot;button&quot;, &quot;Bitte Klicken&quot;,
   	                     WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
				         0, 40, 150, 30, hwnd, (HMENU) button1,
				         ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ; //Button &quot;=&quot; bzw. Berechne
               SendMessage(hwndbutton1, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);

               hwndbutton2 = CreateWindow (&quot;button&quot;, &quot;Open MessageBox&quot;, 
                          WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_VCENTER,
                          10, 100, 500, 30, hwnd, (HMENU) button2,
                          ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL);
               SendMessage(hwndbutton2, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);

			   return 0 ;

		       case WM_COMMAND:
			   switch (HIWORD(wParam))//Aktionsauswahl
			   {
			          case BN_CLICKED://Button gedrückt ?
				      switch(LOWORD(wParam))//Welcher ?
				      {
                           case button1:
					       SendMessage(hwndedit1,WM_SETTEXT,0,(long)&quot;Der Button wurde gedrückt&quot;);
					       break;

					       case button2:

                           if (SendMessage(hwndedit1, WM_GETTEXT, 0, 0) == (long)&quot;1&quot;)                           
                           SendMessage (hwndedit1, WM_SETTEXT, 0, (long)&quot;2&quot;);
                           else 
                           if (SendMessage(hwndedit1, WM_GETTEXT, 0, 0) == (long)&quot;2&quot;)
                           SendMessage(hwndedit1, WM_SETTEXT, 0, (long)&quot;1&quot;);
                           else
                           MessageBox(hwnd,&quot;gvzgd&quot;,&quot;hbcfe&quot;,0);

                           break;
				       }
				       break;
			  }
			  return 0;

			  case WM_DESTROY :
				  PostQuitMessage (0) ;
				  return 0 ;
	 }
     return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
</code></pre>
<p>Also, das Programm soll eigentlich Wenn man den unteren Button drückt die 1 in der Editbox zu einer 2 machen oder andersrum.</p>
<p>Ich denke der Fehler liegt hier drin:</p>
<pre><code class="language-cpp">if (SendMessage(hwndedit1, WM_GETTEXT, 0, 0) ==(long)&quot;1&quot;) [/code]
</code></pre>
<p>aber ich hab keine ahnung wie ich ihn beheben kann.</p>
<p>Kann mir jemand helfen? <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>Schonmal danke im voraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/927793</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/927793</guid><dc:creator><![CDATA[xehon]]></dc:creator><pubDate>Sat, 26 Nov 2005 17:14:49 GMT</pubDate></item><item><title><![CDATA[Reply to LRESULT -&amp;gt; Char[] bzw. long on Sat, 26 Nov 2005 18:05:55 GMT]]></title><description><![CDATA[<p>Naja, vielleicht solltest Du mal die Doku zu WM_GETTEXT lesen <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="😉"
    /><br />
<a href="http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_gettext.asp" rel="nofollow">http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_gettext.asp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/927849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/927849</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 26 Nov 2005 18:05:55 GMT</pubDate></item><item><title><![CDATA[Reply to LRESULT -&amp;gt; Char[] bzw. long on Sat, 26 Nov 2005 18:30:14 GMT]]></title><description><![CDATA[<p>hey, cooler Tipp!</p>
<p>Und jetzt funkt es sogar, vielen dank!</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
        static HWND hwndedit1, hwndbutton1, hwndbutton2; 
        LRESULT a = 1, b = 2;
        int ilen;
        char puffer[10];
        switch (iMsg)
        {
               case WM_CREATE :
			   hwndedit1 = CreateWindowEx(WS_EX_CLIENTEDGE ,&quot;edit&quot;, NULL,WS_CHILD | WS_VISIBLE | ES_LEFT,
				        0, 0, 150, 20, hwnd, (HMENU) edit1,
				        ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ;
	           SendMessage(hwndedit1, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);

			   hwndbutton1 = CreateWindow (&quot;button&quot;, &quot;Bitte Klicken&quot;,
   	                     WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
				         0, 40, 150, 30, hwnd, (HMENU) button1,
				         ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ; //Button &quot;=&quot; bzw. Berechne
               SendMessage(hwndbutton1, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);

               hwndbutton2 = CreateWindow (&quot;button&quot;, &quot;Open MessageBox&quot;, 
                          WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_VCENTER,
                          10, 100, 500, 30, hwnd, (HMENU) button2,
                          ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL);
               SendMessage(hwndbutton2, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),0);
               SendMessage(hwndedit1, WM_SETTEXT, 0, (long)&quot;1&quot;);       

			   return 0 ;

		       case WM_COMMAND:
			   switch (HIWORD(wParam))//Aktionsauswahl
			   {
			          case BN_CLICKED://Button gedrückt ?
				      switch(LOWORD(wParam))//Welcher ?
				      {
                           case button1:
					       SendMessage(hwndedit1,WM_SETTEXT,0,(long)&quot;Der Button wurde gedrückt&quot;);
					       break;

					       case button2: 	           
                           ilen = SendMessage(hwndedit1,WM_GETTEXTLENGTH,0,0);
                           SendMessage(hwndedit1, WM_GETTEXT, ilen+1, (long)puffer);

                           if (puffer[0] == '1')                           
                           SendMessage (hwndedit1, WM_SETTEXT, 0, (long)&quot;2&quot;);
                           else 
                           if (puffer[0] == '2')
                           SendMessage(hwndedit1, WM_SETTEXT, 0, (long)&quot;1&quot;);
                           else
                           MessageBox(hwnd,&quot;gvzgd&quot;,&quot;hbcfe&quot;,0);

                           break;
				       }
				       break;
			  }
			  return 0;

			  case WM_DESTROY :
				  PostQuitMessage (0) ;
				  return 0 ;
	 }
     return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/927882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/927882</guid><dc:creator><![CDATA[xehon]]></dc:creator><pubDate>Sat, 26 Nov 2005 18:30:14 GMT</pubDate></item><item><title><![CDATA[Reply to LRESULT -&amp;gt; Char[] bzw. long on Sat, 26 Nov 2005 18:35:30 GMT]]></title><description><![CDATA[<p>Naja... ich würde Dir nur mal Raten zu überprüfen, was passiert wenn man mehr als 10 Zeichen eingibt... (i.d.R. wird es abstürzen; aber vielleicht hast Du auch Glück...)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/927889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/927889</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 26 Nov 2005 18:35:30 GMT</pubDate></item><item><title><![CDATA[Reply to LRESULT -&amp;gt; Char[] bzw. long on Sat, 26 Nov 2005 19:08:49 GMT]]></title><description><![CDATA[<p>Ja, danke! <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="😃"
    /> <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>
]]></description><link>https://www.c-plusplus.net/forum/post/927933</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/927933</guid><dc:creator><![CDATA[xehon]]></dc:creator><pubDate>Sat, 26 Nov 2005 19:08:49 GMT</pubDate></item></channel></rss>