<?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[Winapi Editbox fehler]]></title><description><![CDATA[<p>Hallo <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 />
Ich habe ein problem mit dem code (von <a href="http://www.win-api.de/tutorials.php?tutid=18&amp;SessID=5ec51edfb6db3ac87cb044ab95eaa75c" rel="nofollow">http://www.win-api.de/tutorials.php?tutid=18&amp;SessID=5ec51edfb6db3ac87cb044ab95eaa75c</a>)</p>
<p>ich bekomme immer doe fehler meldung : &quot; invalid conversion 'void to 'car &quot;</p>
<p>und der will irgentwas mit den beiden dinger haben:</p>
<p>buffer = malloc(iFileSize);<br />
buffer = malloc(iLength);</p>
<p>wenn ich die aber weg lasse dann schreib der nicht miehr in die test.txt ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>hier der code:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

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

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

    const char szAppName[] = &quot;Editcontrol Tutorial&quot;;

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

    RegisterClass(&amp;wc);

    hWnd = CreateWindow( szAppName,
                         &quot;Editcontrol Tutorial&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 message, WPARAM wParam, LPARAM lParam)
{

    static HWND hEdit;

    switch(message)
    {
    case WM_CREATE:
        {

            FILE *fz;
            char *buffer = NULL;
            int iFileSize;

            fz = fopen(&quot;text.txt&quot;, &quot;rb&quot;);
            if(fz != NULL)
            {
                fseek(fz, 0, SEEK_END);
                iFileSize = ftell(fz);
                buffer = malloc(iFileSize);

                fseek(fz, 0, SEEK_SET);
                fread(buffer, 1, iFileSize, fz);
                fclose(fz);
            }

            hEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
                                   &quot;edit&quot;,
                                   buffer,    // &lt;- das ist der Inhalt der Editfelds
                                   WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE |
                                              ES_AUTOVSCROLL,
                                   0, 0, 0, 0,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);

            free(buffer);

            return 0;
        }
    case WM_SIZE:
        {

            MoveWindow(hEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
            return 0;
        }
    case WM_CLOSE:
        {

            FILE *fz;
            char *buffer = NULL;
            int iLength;

            iLength = GetWindowTextLength(hEdit);

            buffer = malloc(iLength);

            GetWindowText(hEdit, buffer, iLength+1);

            fz = fopen(&quot;text.txt&quot;, &quot;wb&quot;);
            fwrite(buffer, 1, iLength, fz);
            fclose(fz);

            free(buffer);

            DestroyWindow(hWnd);
            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/201050/winapi-editbox-fehler</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 08:30:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/201050.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 23 Dec 2007 17:03:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Winapi Editbox fehler on Sun, 23 Dec 2007 17:03:41 GMT]]></title><description><![CDATA[<p>Hallo <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 />
Ich habe ein problem mit dem code (von <a href="http://www.win-api.de/tutorials.php?tutid=18&amp;SessID=5ec51edfb6db3ac87cb044ab95eaa75c" rel="nofollow">http://www.win-api.de/tutorials.php?tutid=18&amp;SessID=5ec51edfb6db3ac87cb044ab95eaa75c</a>)</p>
<p>ich bekomme immer doe fehler meldung : &quot; invalid conversion 'void to 'car &quot;</p>
<p>und der will irgentwas mit den beiden dinger haben:</p>
<p>buffer = malloc(iFileSize);<br />
buffer = malloc(iLength);</p>
<p>wenn ich die aber weg lasse dann schreib der nicht miehr in die test.txt ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>hier der code:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

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

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

    const char szAppName[] = &quot;Editcontrol Tutorial&quot;;

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

    RegisterClass(&amp;wc);

    hWnd = CreateWindow( szAppName,
                         &quot;Editcontrol Tutorial&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 message, WPARAM wParam, LPARAM lParam)
{

    static HWND hEdit;

    switch(message)
    {
    case WM_CREATE:
        {

            FILE *fz;
            char *buffer = NULL;
            int iFileSize;

            fz = fopen(&quot;text.txt&quot;, &quot;rb&quot;);
            if(fz != NULL)
            {
                fseek(fz, 0, SEEK_END);
                iFileSize = ftell(fz);
                buffer = malloc(iFileSize);

                fseek(fz, 0, SEEK_SET);
                fread(buffer, 1, iFileSize, fz);
                fclose(fz);
            }

            hEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
                                   &quot;edit&quot;,
                                   buffer,    // &lt;- das ist der Inhalt der Editfelds
                                   WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE |
                                              ES_AUTOVSCROLL,
                                   0, 0, 0, 0,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);

            free(buffer);

            return 0;
        }
    case WM_SIZE:
        {

            MoveWindow(hEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
            return 0;
        }
    case WM_CLOSE:
        {

            FILE *fz;
            char *buffer = NULL;
            int iLength;

            iLength = GetWindowTextLength(hEdit);

            buffer = malloc(iLength);

            GetWindowText(hEdit, buffer, iLength+1);

            fz = fopen(&quot;text.txt&quot;, &quot;wb&quot;);
            fwrite(buffer, 1, iLength, fz);
            fclose(fz);

            free(buffer);

            DestroyWindow(hWnd);
            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/1425264</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1425264</guid><dc:creator><![CDATA[:) Patrick :)]]></dc:creator><pubDate>Sun, 23 Dec 2007 17:03:41 GMT</pubDate></item><item><title><![CDATA[Reply to Winapi Editbox fehler on Sun, 23 Dec 2007 18:51:02 GMT]]></title><description><![CDATA[<p>Hi probiers mal so:</p>
<pre><code class="language-cpp">buffer = (char *) malloc(iFileSize);
buffer = (char *) malloc(iLength);
</code></pre>
<p>Malloc liefert einen Zeiger auf void muss, da C++-Compiler das nicht akzeptieren, gecastet (explizite Typenumwandlung) werden.</p>
<p>Wenn du für buffer keinen Speicherplatz reservierst, kann GetWindowText dort nicht den Text reinschreiben.</p>
<pre><code class="language-cpp">GetWindowText(hEdit, buffer, iLength+1);
</code></pre>
<p>Folglich wird in die Datei die leere Variable buffer via</p>
<pre><code class="language-cpp">fwrite(buffer, 1, iLength, fz)
</code></pre>
<p>geschrieben.</p>
<p>MfG WilMen :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1425325</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1425325</guid><dc:creator><![CDATA[WilMen]]></dc:creator><pubDate>Sun, 23 Dec 2007 18:51:02 GMT</pubDate></item><item><title><![CDATA[Reply to Winapi Editbox fehler on Sun, 23 Dec 2007 19:02:28 GMT]]></title><description><![CDATA[<p>schön , tuts aber es steht nix in der test.txt datei <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 hab alles genau so gemacht wie du wolltes</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1425328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1425328</guid><dc:creator><![CDATA[:) Patrick :)]]></dc:creator><pubDate>Sun, 23 Dec 2007 19:02:28 GMT</pubDate></item><item><title><![CDATA[Reply to Winapi Editbox fehler on Sun, 23 Dec 2007 19:12:33 GMT]]></title><description><![CDATA[<p>also gut , hier ist der neue code <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;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt; 

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

int WINAPI WinMain (HINSTANCE hI, HINSTANCE hPrI, PSTR szCmdLine, int iCmdShow)
{
 char szName[] = &quot;Fensterklasse&quot;;
 HBRUSH MyBrush = CreateSolidBrush( RGB( 212, 208, 200 ) );
 WNDCLASS wc;

 wc.style         = CS_HREDRAW | CS_VREDRAW;
 wc.lpfnWndProc   = WndProc;
 wc.cbClsExtra    = 0;
 wc.cbWndExtra    = 0;
 wc.hInstance     = hI;
 wc.hIcon         = LoadIcon (NULL, IDI_WINLOGO);
 wc.hCursor       = 0;
 wc.hbrBackground = MyBrush;
 wc.lpszMenuName  = NULL;
 wc.lpszClassName = szName;

 RegisterClass (&amp;wc);

 HWND hwnd = CreateWindow (szName, &quot;PPH&quot;, WS_OVERLAPPEDWINDOW,
                            0, 0, 400, 100, NULL, NULL, hI, NULL);
 ShowWindow   (hwnd, iCmdShow);
 UpdateWindow (hwnd);

//-----------------------------------------------------------------------------------

  MSG msg;

  while (GetMessage (&amp;msg, NULL, 0, 0))
  {
    TranslateMessage (&amp;msg);
    DispatchMessage  (&amp;msg);
  }
  return msg.wParam;
} 
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
 HDC hdc;
 PAINTSTRUCT ps;
 static HWND hwndEdit1, hwndEdit2 ,hwndEdit3;

 switch (message)
 {
  case WM_PAINT:
      hdc = BeginPaint (hwnd, &amp;ps);
      SetTextColor(hdc, RGB(0,0,0) );
      SetBkColor(hdc, RGB(212,208,200) );
      TextOut (hdc, 20, 10, &quot;Name:&quot;, 5);
      TextOut (hdc, 20, 30, &quot;Icq Adresse:&quot;, 12);
      TextOut (hdc, 20, 50, &quot;Icq Passwort:&quot;, 13);
      EndPaint (hwnd, &amp;ps);
  return 0;

  case WM_CREATE :
  {

   FILE *fz;
            char *buffer = NULL;
            int iFileSize;

            fz = fopen(&quot;text.txt&quot;, &quot;rb&quot;);
            if(fz != NULL)
            {
                fseek(fz, 0, SEEK_END);
                iFileSize = ftell(fz);
                buffer = (char *) malloc(iFileSize); 
                fseek(fz, 0, SEEK_SET);
                fread(buffer, 1, iFileSize, fz);
                fclose(fz);
            }

  hwndEdit1   = CreateWindow ( &quot;edit&quot;, &quot;&quot;,
                                   WS_CHILD | WS_VISIBLE ,
                                   150, 10, 100, 16, hwnd, (HMENU)2,
                                   (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL); 

  hwndEdit2  = CreateWindow ( &quot;edit&quot;, &quot;&quot;,
                                   WS_CHILD | WS_VISIBLE ,
                                   150, 30, 100, 16, hwnd, (HMENU)2,
                                   (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL); 

  hwndEdit3  = CreateWindow ( &quot;edit&quot;, &quot;&quot;,
                                   WS_CHILD | WS_VISIBLE| ES_PASSWORD,
                                   150, 50, 100, 16, hwnd, (HMENU)2,
                                   (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL); 
  free(buffer); 
  return 0;
}
  case WM_COMMAND:
      switch(LOWORD(wParam))
      {

      case 1:
           SetWindowText(hwndEdit2,&quot;&quot;);
           SendMessage(hwndEdit2, EM_SETREADONLY, TRUE, 0);
      break;
      case 2:
           SendMessage(hwndEdit2, EM_SETREADONLY, FALSE, 0);
      break;
      }
  return 0;

 case WM_CLOSE:
 {
  FILE *fz;
  char* buffer = NULL;
  int  iLength;
  iLength = GetWindowText(hwndEdit1, buffer, iLength+1);
  iLength = GetWindowText(hwndEdit2, buffer, iLength+2);
  iLength = GetWindowText(hwndEdit3, buffer, iLength+3);
  buffer = (char *) malloc(iLength);
  GetWindowText(hwndEdit1, buffer, iLength+1);
  fz = fopen(&quot;text.txt&quot;, &quot;wb&quot;);
  fwrite(buffer, 1, iLength, fz);
  fwrite(buffer, 2, iLength, fz);
  fwrite(buffer, 3, iLength, fz);
  fclose(fz);
  free(buffer);
  DestroyWindow(hwnd);
  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/1425335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1425335</guid><dc:creator><![CDATA[:) Patrick :)]]></dc:creator><pubDate>Sun, 23 Dec 2007 19:12:33 GMT</pubDate></item><item><title><![CDATA[Reply to Winapi Editbox fehler on Sun, 23 Dec 2007 19:37:17 GMT]]></title><description><![CDATA[<p>habs schon ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1425343</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1425343</guid><dc:creator><![CDATA[:) patrick :)]]></dc:creator><pubDate>Sun, 23 Dec 2007 19:37:17 GMT</pubDate></item></channel></rss>