<?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[simples WinAPI programm]]></title><description><![CDATA[<p>Hi,</p>
<pre><code class="language-cpp">#define STRICT
#include &quot;stdafx.h&quot;
#include &lt;windows.h&gt;
#include &lt;string.h&gt;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
char Name [] = &quot;Ein eigenes Fenster&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 =  Name;
   wc.lpszMenuName  =  NULL;
   RegisterClass(&amp;wc);
   hWnd = CreateWindow(Name,
                       &quot;Titelleiste&quot;,
                       WS_OVERLAPPEDWINDOW,
                       CW_USEDEFAULT,          /* X-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Y-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Fensterbreite              */
                       CW_USEDEFAULT,          /* Fensterhoehe               */
                       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)
{
   switch (message)
   {
	  case WM_DESTROY:
      {
         PostQuitMessage(0);
         return 0;
      }
   }
   return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
<p>als fehlermeldungen bekomme ich:</p>
<p>[code]</p>
<p>error C2440: '=' : cannot convert from 'char [20]' to 'LPCWSTR'</p>
<p>error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [20]' to 'LPCWSTR'</p>
<p>[code]</p>
<p>So, nun hab ich aber ka wie ich die fehlermeldungen beseitign kann...?</p>
<p>thx</p>
<p>mfg,<br />
xehon</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/118149/simples-winapi-programm</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 21:56:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118149.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Aug 2005 16:57:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to simples WinAPI programm on Mon, 15 Aug 2005 16:57:11 GMT]]></title><description><![CDATA[<p>Hi,</p>
<pre><code class="language-cpp">#define STRICT
#include &quot;stdafx.h&quot;
#include &lt;windows.h&gt;
#include &lt;string.h&gt;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
char Name [] = &quot;Ein eigenes Fenster&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 =  Name;
   wc.lpszMenuName  =  NULL;
   RegisterClass(&amp;wc);
   hWnd = CreateWindow(Name,
                       &quot;Titelleiste&quot;,
                       WS_OVERLAPPEDWINDOW,
                       CW_USEDEFAULT,          /* X-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Y-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Fensterbreite              */
                       CW_USEDEFAULT,          /* Fensterhoehe               */
                       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)
{
   switch (message)
   {
	  case WM_DESTROY:
      {
         PostQuitMessage(0);
         return 0;
      }
   }
   return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
<p>als fehlermeldungen bekomme ich:</p>
<p>[code]</p>
<p>error C2440: '=' : cannot convert from 'char [20]' to 'LPCWSTR'</p>
<p>error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [20]' to 'LPCWSTR'</p>
<p>[code]</p>
<p>So, nun hab ich aber ka wie ich die fehlermeldungen beseitign kann...?</p>
<p>thx</p>
<p>mfg,<br />
xehon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852716</guid><dc:creator><![CDATA[xehon]]></dc:creator><pubDate>Mon, 15 Aug 2005 16:57:11 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Mon, 15 Aug 2005 17:02:01 GMT]]></title><description><![CDATA[<p>Irgendwo hast du UNICODE-Kompilierung eingeschaltet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852724</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852724</guid><dc:creator><![CDATA[.........]]></dc:creator><pubDate>Mon, 15 Aug 2005 17:02:01 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Mon, 15 Aug 2005 17:16:03 GMT]]></title><description><![CDATA[<p>und wo kannn man dass ausschalten??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852736</guid><dc:creator><![CDATA[xehon (offline)]]></dc:creator><pubDate>Mon, 15 Aug 2005 17:16:03 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Mon, 15 Aug 2005 17:16:56 GMT]]></title><description><![CDATA[<p>Welchen Compiler/IDE benutzt du?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852738</guid><dc:creator><![CDATA[ich (online)]]></dc:creator><pubDate>Mon, 15 Aug 2005 17:16:56 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Mon, 15 Aug 2005 17:19:29 GMT]]></title><description><![CDATA[<p>mvc++ express edition beta 2</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852740</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852740</guid><dc:creator><![CDATA[xehon (offline)]]></dc:creator><pubDate>Mon, 15 Aug 2005 17:19:29 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Mon, 15 Aug 2005 17:44:05 GMT]]></title><description><![CDATA[<p>oh den hab ich nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>such mal in den projektoptionen nach Präprozessordefinitionen und lösch UNICODE und UNICODE_ falls es dort drinstehen sollte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852757</guid><dc:creator><![CDATA[ich (online)]]></dc:creator><pubDate>Mon, 15 Aug 2005 17:44:05 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Mon, 15 Aug 2005 19:13:17 GMT]]></title><description><![CDATA[<p>evtl. hilft viellecht auch ein #undef _UNICODE nach dem #define STRICT</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852840</guid><dc:creator><![CDATA[miller_m]]></dc:creator><pubDate>Mon, 15 Aug 2005 19:13:17 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 05:32:19 GMT]]></title><description><![CDATA[<p>Wozu brachst Du</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
</code></pre>
<p>wenn Du doch nicht MFC machst? Lasse den Header weg und stelle als Projekt einfach eine Win32-Applikation ein. Schon gehts.</p>
<p>Trotzdem noch ein paar Änderungen:</p>
<p>statt:</p>
<pre><code class="language-cpp">char Name [] = &quot;Ein eigenes Fenster&quot;;
</code></pre>
<p>besser</p>
<pre><code class="language-cpp">TCHAR Name [] = &quot;Ein eigenes Fenster&quot;;
</code></pre>
<p>und</p>
<pre><code class="language-cpp">&quot;Titelleiste&quot;
</code></pre>
<p>besser</p>
<pre><code class="language-cpp">TEXT(&quot;Titelleiste&quot;)
</code></pre>
<p>Blackbird</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852985</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852985</guid><dc:creator><![CDATA[*zufaulzumeinloggen*]]></dc:creator><pubDate>Tue, 16 Aug 2005 05:32:19 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 05:41:25 GMT]]></title><description><![CDATA[<p><em>zufaulzumeinloggen</em> schrieb:</p>
<blockquote>
<p>Wozu brachst Du</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
</code></pre>
<p>wenn Du doch nicht MFC machst? Lasse den Header weg und stelle als Projekt einfach eine Win32-Applikation ein. Schon gehts.</p>
</blockquote>
<p>Diese Datei hat NICHTS mit MFC zu tun. Sie wird für die vorcompilierten Header<br />
verwendet und kann über die Projekteinstellungen deaktiviert werden. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/852989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852989</guid><dc:creator><![CDATA[Redhead]]></dc:creator><pubDate>Tue, 16 Aug 2005 05:41:25 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 06:16:17 GMT]]></title><description><![CDATA[<p>das mit dem Unicode steht vielleicht in der stdafx.h datei</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852999</guid><dc:creator><![CDATA[vielleicht...]]></dc:creator><pubDate>Tue, 16 Aug 2005 06:16:17 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 09:10:19 GMT]]></title><description><![CDATA[<p>Redhead, hast recht. Hab's verwechselt. Ist noch zu früh für mich <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="🙂"
    /></p>
<pre><code class="language-cpp">#define STRICT
#include &lt;string.h&gt;
</code></pre>
<p>kann auch weg.</p>
<p>Blackbird</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853124</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853124</guid><dc:creator><![CDATA[*zufaulzumeinloggen*]]></dc:creator><pubDate>Tue, 16 Aug 2005 09:10:19 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 15:28:51 GMT]]></title><description><![CDATA[<p>Okay, ich habs jetzt verbessert.</p>
<p>Aber ich bekomme immer noch eine Fehlermeldung:</p>
<p>error C2440: 'initializing' : cannot convert from 'const char [20]' to 'TCHAR []'</p>
<p>obwohl ich</p>
<p>TCHAR Name [] = &quot;Ein eigenes Fenster&quot;;</p>
<p>geschrieben hab</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853518</guid><dc:creator><![CDATA[xehon]]></dc:creator><pubDate>Tue, 16 Aug 2005 15:28:51 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 15:44:26 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">TCHAR Name [] = L&quot;Ein eigenes Fenster&quot;;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/853532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853532</guid><dc:creator><![CDATA[miller_m]]></dc:creator><pubDate>Tue, 16 Aug 2005 15:44:26 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 15:45:18 GMT]]></title><description><![CDATA[<p>*zufaulzumeinloggen* hat's ja schon gesagt.<br />
TCHAR Name [] = TEXT(&quot;Ein eigenes Fenster&quot;);<br />
Kurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853533</guid><dc:creator><![CDATA[ZuK]]></dc:creator><pubDate>Tue, 16 Aug 2005 15:45:18 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 17:11:50 GMT]]></title><description><![CDATA[<p>okay,</p>
<p>ich habs jetzt so:</p>
<pre><code class="language-cpp">#define STRICT
#undef _UNICODE
#include &quot;stdafx.h&quot;
#include &lt;windows.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
TCHAR Name [] = TEXT(&quot;Ein eigenes Fenster&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 =  Name;
   wc.lpszMenuName  =  NULL;
   RegisterClass(&amp;wc);
   hWnd = CreateWindow(Name,
                       TEXT(&quot;Titelleiste&quot;),
                       WS_OVERLAPPEDWINDOW,
                       CW_USEDEFAULT,          /* X-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Y-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Fensterbreite              */
                       CW_USEDEFAULT,          /* Fensterhoehe               */
                       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)
{
   switch (message)
   {
	  case WM_DESTROY:
      {
         PostQuitMessage(0);
         return 0;
      }
   }
   return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
<p>aber jetzt bekomme ich sogar 14 fehlermeldungen:</p>
<pre><code>Linking...
window.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageW@4 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__GetMessageW@16 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__UpdateWindow@4 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__ShowWindow@8 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExW@48 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__RegisterClassW@4 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__GetStockObject@4 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__LoadIconW@8 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__LoadCursorW@8 referenced in function _WinMain@16
window.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcW@16 referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@YGJPAUHWND__@@IIJ@Z)
window.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage@4 referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@YGJPAUHWND__@@IIJ@Z)
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
Debug\window.exe : fatal error LNK1120: 13 unresolved externals
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/853590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853590</guid><dc:creator><![CDATA[xehon]]></dc:creator><pubDate>Tue, 16 Aug 2005 17:11:50 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Tue, 16 Aug 2005 17:19:56 GMT]]></title><description><![CDATA[<p>hmm, ich habs mal mit dem dev-cpp versaucht und dort hats geklappt <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>
]]></description><link>https://www.c-plusplus.net/forum/post/853593</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853593</guid><dc:creator><![CDATA[xehon]]></dc:creator><pubDate>Tue, 16 Aug 2005 17:19:56 GMT</pubDate></item><item><title><![CDATA[Reply to simples WinAPI programm on Wed, 17 Aug 2005 07:01:33 GMT]]></title><description><![CDATA[<p>mit</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
</code></pre>
<p>?</p>
<p>Statt</p>
<pre><code class="language-cpp">#define STRICT
#undef _UNICODE
#include &quot;stdafx.h&quot;
#include &lt;windows.h&gt;
</code></pre>
<p>genügt</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
</code></pre>
<p>Vorkompilierte Header brauchst Du nicht, weil sie nicht zu Deinem Projekt pass(t)en.</p>
<p>Blackbird</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853856</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853856</guid><dc:creator><![CDATA[*zufaulzumeinloggen*]]></dc:creator><pubDate>Wed, 17 Aug 2005 07:01:33 GMT</pubDate></item></channel></rss>