<?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[Fehler in Code (Code::Blocks)]]></title><description><![CDATA[<p>Hallo zusammen !<br />
Ich habe diese Code:</p>
<pre><code>LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static int   cxClientMax, cyClientMax, cxClient, cyClient, cxChar, cyChar ;
     static int   cLinesMax, cLines ;
     static PMSG  pmsg ;
     static RECT  rectScroll ;

     static TCHAR szTop[] = TEXT (&quot;Nachricht      Taste   Zeichen      Wdh.  &quot;)
                            TEXT (&quot;OEM-Code Erw. ALT   vorher  jetzt&quot;) ;
     static TCHAR szUnd[] = TEXT (&quot;_________      _____   _______      ____  &quot;)
                            TEXT (&quot;________ ____ ___   ______  ________&quot;) ;

     static TCHAR * szFormat[2] = {
               TEXT (&quot;%-13s %3d %-13s%c%6u  %4d       %4s %4s %8s %8s&quot;),
               TEXT (&quot;%-13s          0x%04X%1s%c %6u  %4d       %4s %4s %8s %8s&quot;) } ;
     static TCHAR * szYes  = TEXT (&quot;Ja&quot;) ;
     static TCHAR * szNo   = TEXT (&quot;Nein&quot;) ;
     static TCHAR * szDown = TEXT (&quot;gedrückt&quot;) ;
     static TCHAR * szUp   = TEXT (&quot;gelöst&quot;) ;

     static TCHAR * szMessage [] = {
                         TEXT (&quot;WM_KEYDOWN&quot;),    TEXT (&quot;WM_KEYUP&quot;),
                         TEXT (&quot;WM_CHAR&quot;),       TEXT (&quot;WM_DEADCHAR&quot;),
                         TEXT (&quot;WM_SYSKEYDOWN&quot;), TEXT (&quot;WM_SYSKEYUP&quot;),
                         TEXT (&quot;WM_SYSCHAR&quot;),    TEXT (&quot;WM_SYSDEADCHAR&quot;) } ;
     HDC          hdc ;
     int          i, iType ;
     PAINTSTRUCT  ps ;
     TCHAR        szBuffer[128], szKeyName [32] ;
     TEXTMETRIC   tm ;

     switch (message)
     {
     case WM_CREATE:
     case WM_DISPLAYCHANGE:

          // Maximalgröße des Anwendungsbereichs ermitteln
          cxClientMax = GetSystemMetrics (SM_CXMAXIMIZED) ;
          cyClientMax = GetSystemMetrics (SM_CYMAXIMIZED) ;

          // Zeichengröße für nicht proportionale Systemschrift
          hdc = GetDC (hwnd) ;

          SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)) ;
          GetTextMetrics (hdc, &amp;tm) ;
          cxChar = tm.tmAveCharWidth ;
          cyChar = tm.tmHeight ;

          ReleaseDC (hwnd, hdc) ;

          // Speicherplatz für die Ausgabezeilen
          if (pmsg)
               free (pmsg) ;

          cLinesMax = cyClientMax / cyChar ;
          pmsg = malloc(cLinesMax * sizeof(MSG)) ;
          cLines = 0 ;
                                   // weiter mit WM_SIZE
      case WM_SIZE:
          if (message == WM_SIZE)
          {
               cxClient = LOWORD (lParam) ;
               cyClient = HIWORD (lParam) ;
          }
          // Rechteck für ScrollWindow
          rectScroll.left   = 0 ;
          rectScroll.right  = cxClient ;
          rectScroll.top    = cyChar ;
          rectScroll.bottom = cyChar * (cyClient / cyChar) ;

          InvalidateRect (hwnd, NULL, TRUE) ;
          return 0 ;

     case WM_KEYDOWN:
     case WM_KEYUP:
     case WM_CHAR:
     case WM_DEADCHAR:
     case WM_SYSKEYDOWN:
     case WM_SYSKEYUP:
     case WM_SYSCHAR:
     case WM_SYSDEADCHAR:

          // bereits gespeicherte Nachrichten nach hinten umstapeln
          for (i = cLinesMax - 1 ; i &gt; 0 ; i--)
          {
               pmsg[i] = pmsg[i - 1] ;
          }
          // und neues Ereignis ins Element 0
          pmsg[0].hwnd = hwnd ;
          pmsg[0].message = message ;
          pmsg[0].wParam = wParam ;
          pmsg[0].lParam = lParam ;

          cLines = min (cLines + 1, cLinesMax) ;

           // Anzeige um eine Zeile nach oben
          ScrollWindow (hwnd, 0, -cyChar, &amp;rectScroll, &amp;rectScroll) ;

          break ;        // -&gt; DefWindowProc - sonst würden Systemtasten nicht mehr funktionieren

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &amp;ps) ;

          SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)) ;
          SetBkMode (hdc, TRANSPARENT) ;
          TextOut (hdc, 0, 0, szTop, lstrlen (szTop)) ;
          TextOut (hdc, 0, 0, szUnd, lstrlen (szUnd)) ;

          for (i = 0 ; i &lt; min (cLines, cyClient / cyChar - 1) ; i++)
          {
               iType = pmsg[i].message == WM_CHAR ||
                       pmsg[i].message == WM_SYSCHAR ||
                       pmsg[i].message == WM_DEADCHAR ||
                       pmsg[i].message == WM_SYSDEADCHAR ;

               GetKeyNameText (pmsg[i].lParam, szKeyName, sizeof (szKeyName) / sizeof (TCHAR)) ;

               TextOut (hdc, 0, (cyClient / cyChar - 1 - i) * cyChar, szBuffer,
                        wsprintf (szBuffer, szFormat [iType],
                             szMessage [pmsg[i].message - WM_KEYFIRST],
                             pmsg[i].wParam,
                             (PTSTR) (iType ? TEXT (&quot; &quot;) : szKeyName),
                             (TCHAR) (iType ? pmsg[i].wParam : ' '),
                             LOWORD (pmsg[i].lParam),
                             HIWORD (pmsg[i].lParam) &amp; 0xFF,
                             0x01000000 &amp; pmsg[i].lParam ? szYes  : szNo,
                             0x20000000 &amp; pmsg[i].lParam ? szYes  : szNo,
                             0x40000000 &amp; pmsg[i].lParam ? szDown : szUp,
                             0x80000000 &amp; pmsg[i].lParam ? szUp   : szDown)) ;
          }
          EndPaint (hwnd, &amp;ps) ;
          return 0 ;

     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
<p>Diese Code gibt in Form status eine Taste aus (gedrückt/los gelassen)</p>
<p>Nur beim Kompilieren zeigt er mir in Zeile 56 folgende Fehler an:<br />
invalid conversion from 'void*' to 'PMSG {aka tagMSG*}' [-fpermissive]|</p>
<p>Wie kann ich diesen Fehler beheben ?<br />
In Zeile 13 steht das hier: %-13s %3d %-13s%c%6u %4d<br />
was hat das alles zu bedeuten ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/314710/fehler-in-code-code-blocks</link><generator>RSS for Node</generator><lastBuildDate>Fri, 31 Jul 2026 23:31:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314710.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 11 Mar 2013 18:28:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler in Code (Code::Blocks) on Mon, 11 Mar 2013 18:32:35 GMT]]></title><description><![CDATA[<p>Hallo zusammen !<br />
Ich habe diese Code:</p>
<pre><code>LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static int   cxClientMax, cyClientMax, cxClient, cyClient, cxChar, cyChar ;
     static int   cLinesMax, cLines ;
     static PMSG  pmsg ;
     static RECT  rectScroll ;

     static TCHAR szTop[] = TEXT (&quot;Nachricht      Taste   Zeichen      Wdh.  &quot;)
                            TEXT (&quot;OEM-Code Erw. ALT   vorher  jetzt&quot;) ;
     static TCHAR szUnd[] = TEXT (&quot;_________      _____   _______      ____  &quot;)
                            TEXT (&quot;________ ____ ___   ______  ________&quot;) ;

     static TCHAR * szFormat[2] = {
               TEXT (&quot;%-13s %3d %-13s%c%6u  %4d       %4s %4s %8s %8s&quot;),
               TEXT (&quot;%-13s          0x%04X%1s%c %6u  %4d       %4s %4s %8s %8s&quot;) } ;
     static TCHAR * szYes  = TEXT (&quot;Ja&quot;) ;
     static TCHAR * szNo   = TEXT (&quot;Nein&quot;) ;
     static TCHAR * szDown = TEXT (&quot;gedrückt&quot;) ;
     static TCHAR * szUp   = TEXT (&quot;gelöst&quot;) ;

     static TCHAR * szMessage [] = {
                         TEXT (&quot;WM_KEYDOWN&quot;),    TEXT (&quot;WM_KEYUP&quot;),
                         TEXT (&quot;WM_CHAR&quot;),       TEXT (&quot;WM_DEADCHAR&quot;),
                         TEXT (&quot;WM_SYSKEYDOWN&quot;), TEXT (&quot;WM_SYSKEYUP&quot;),
                         TEXT (&quot;WM_SYSCHAR&quot;),    TEXT (&quot;WM_SYSDEADCHAR&quot;) } ;
     HDC          hdc ;
     int          i, iType ;
     PAINTSTRUCT  ps ;
     TCHAR        szBuffer[128], szKeyName [32] ;
     TEXTMETRIC   tm ;

     switch (message)
     {
     case WM_CREATE:
     case WM_DISPLAYCHANGE:

          // Maximalgröße des Anwendungsbereichs ermitteln
          cxClientMax = GetSystemMetrics (SM_CXMAXIMIZED) ;
          cyClientMax = GetSystemMetrics (SM_CYMAXIMIZED) ;

          // Zeichengröße für nicht proportionale Systemschrift
          hdc = GetDC (hwnd) ;

          SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)) ;
          GetTextMetrics (hdc, &amp;tm) ;
          cxChar = tm.tmAveCharWidth ;
          cyChar = tm.tmHeight ;

          ReleaseDC (hwnd, hdc) ;

          // Speicherplatz für die Ausgabezeilen
          if (pmsg)
               free (pmsg) ;

          cLinesMax = cyClientMax / cyChar ;
          pmsg = malloc(cLinesMax * sizeof(MSG)) ;
          cLines = 0 ;
                                   // weiter mit WM_SIZE
      case WM_SIZE:
          if (message == WM_SIZE)
          {
               cxClient = LOWORD (lParam) ;
               cyClient = HIWORD (lParam) ;
          }
          // Rechteck für ScrollWindow
          rectScroll.left   = 0 ;
          rectScroll.right  = cxClient ;
          rectScroll.top    = cyChar ;
          rectScroll.bottom = cyChar * (cyClient / cyChar) ;

          InvalidateRect (hwnd, NULL, TRUE) ;
          return 0 ;

     case WM_KEYDOWN:
     case WM_KEYUP:
     case WM_CHAR:
     case WM_DEADCHAR:
     case WM_SYSKEYDOWN:
     case WM_SYSKEYUP:
     case WM_SYSCHAR:
     case WM_SYSDEADCHAR:

          // bereits gespeicherte Nachrichten nach hinten umstapeln
          for (i = cLinesMax - 1 ; i &gt; 0 ; i--)
          {
               pmsg[i] = pmsg[i - 1] ;
          }
          // und neues Ereignis ins Element 0
          pmsg[0].hwnd = hwnd ;
          pmsg[0].message = message ;
          pmsg[0].wParam = wParam ;
          pmsg[0].lParam = lParam ;

          cLines = min (cLines + 1, cLinesMax) ;

           // Anzeige um eine Zeile nach oben
          ScrollWindow (hwnd, 0, -cyChar, &amp;rectScroll, &amp;rectScroll) ;

          break ;        // -&gt; DefWindowProc - sonst würden Systemtasten nicht mehr funktionieren

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &amp;ps) ;

          SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)) ;
          SetBkMode (hdc, TRANSPARENT) ;
          TextOut (hdc, 0, 0, szTop, lstrlen (szTop)) ;
          TextOut (hdc, 0, 0, szUnd, lstrlen (szUnd)) ;

          for (i = 0 ; i &lt; min (cLines, cyClient / cyChar - 1) ; i++)
          {
               iType = pmsg[i].message == WM_CHAR ||
                       pmsg[i].message == WM_SYSCHAR ||
                       pmsg[i].message == WM_DEADCHAR ||
                       pmsg[i].message == WM_SYSDEADCHAR ;

               GetKeyNameText (pmsg[i].lParam, szKeyName, sizeof (szKeyName) / sizeof (TCHAR)) ;

               TextOut (hdc, 0, (cyClient / cyChar - 1 - i) * cyChar, szBuffer,
                        wsprintf (szBuffer, szFormat [iType],
                             szMessage [pmsg[i].message - WM_KEYFIRST],
                             pmsg[i].wParam,
                             (PTSTR) (iType ? TEXT (&quot; &quot;) : szKeyName),
                             (TCHAR) (iType ? pmsg[i].wParam : ' '),
                             LOWORD (pmsg[i].lParam),
                             HIWORD (pmsg[i].lParam) &amp; 0xFF,
                             0x01000000 &amp; pmsg[i].lParam ? szYes  : szNo,
                             0x20000000 &amp; pmsg[i].lParam ? szYes  : szNo,
                             0x40000000 &amp; pmsg[i].lParam ? szDown : szUp,
                             0x80000000 &amp; pmsg[i].lParam ? szUp   : szDown)) ;
          }
          EndPaint (hwnd, &amp;ps) ;
          return 0 ;

     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
<p>Diese Code gibt in Form status eine Taste aus (gedrückt/los gelassen)</p>
<p>Nur beim Kompilieren zeigt er mir in Zeile 56 folgende Fehler an:<br />
invalid conversion from 'void*' to 'PMSG {aka tagMSG*}' [-fpermissive]|</p>
<p>Wie kann ich diesen Fehler beheben ?<br />
In Zeile 13 steht das hier: %-13s %3d %-13s%c%6u %4d<br />
was hat das alles zu bedeuten ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2305873</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2305873</guid><dc:creator><![CDATA[Alexey]]></dc:creator><pubDate>Mon, 11 Mar 2013 18:32:35 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in Code (Code::Blocks) on Mon, 11 Mar 2013 19:00:30 GMT]]></title><description><![CDATA[<p>Das Ergebnis von malloc() ist vom Typ void*.<br />
Das kann nicht nach PMSG konvertiert werden.<br />
Deswegen muss man es casten.</p>
<pre><code>pmsg = (PMSG)malloc(cLinesMax * sizeof(MSG)) ;
</code></pre>
<p>malloc() ist übrigens aus C. In C++ nutzt man stattdessen new.</p>
<pre><code>pmsg = new MSG [cLinesMax];
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2305887</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2305887</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 11 Mar 2013 19:00:30 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in Code (Code::Blocks) on Tue, 12 Mar 2013 15:59:56 GMT]]></title><description><![CDATA[<p>Hallo Nathan !<br />
Danke, es hats geklappt. Ja ich weis dass &quot;malloc&quot; aus C kommt.<br />
Bin noch in Lernphase.<br />
Eine frage noch offen, was hat das alles zu bedeuten:</p>
<pre><code>static TCHAR * szFormat[2] = {
               TEXT (&quot;%-13s %3d %-13s%c%6u  %4d       %4s %4s %8s %8s&quot;),
               TEXT (&quot;%-13s          0x%04X%1s%c %6u  %4d       %4s %4s %8s %8s&quot;) } ;
</code></pre>
<p>Ich meine das hier &quot;%-13s %3d %-13s%c%6u %4d %4s %4s %8s %8s&quot;, wie soll ich das verstehen ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2306174</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2306174</guid><dc:creator><![CDATA[Alexey]]></dc:creator><pubDate>Tue, 12 Mar 2013 15:59:56 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in Code (Code::Blocks) on Tue, 12 Mar 2013 16:03:03 GMT]]></title><description><![CDATA[<p>c2010 schrieb:</p>
<blockquote>
<p>wie soll ich das verstehen?</p>
</blockquote>
<p>Siehe <a href="http://en.cppreference.com/w/cpp/io/c/fprintf" rel="nofollow">Tabelle</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2306176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2306176</guid><dc:creator><![CDATA[Caligulaminus]]></dc:creator><pubDate>Tue, 12 Mar 2013 16:03:03 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler in Code (Code::Blocks) on Wed, 13 Mar 2013 11:56:46 GMT]]></title><description><![CDATA[<p>Caligulaminus Danke für Hilfreichen Link.<br />
Thema erledigt !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2306379</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2306379</guid><dc:creator><![CDATA[Alexey]]></dc:creator><pubDate>Wed, 13 Mar 2013 11:56:46 GMT</pubDate></item></channel></rss>