<?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[Wie erstelle ich ein window ????]]></title><description><![CDATA[<p>hallo ich war mit dem problem hier schon im Borland Builder Forum dort haben wir das thema dann soweit durch gekaut das ich diese frage hier in dem forum posten soll *verwirrend grml* es geht darum das ich ein fenster zum laufen bekommen (heute angefangen hat, in Win API sich ein zuarbeiten) mein quelltext ist im soweit ausgeschrieben... doch mir wurde gesagt das die funktion GetMessage() fehlt um den &quot;leerlaufprozess&quot; zu garantieren also nur ein wisses Window zu sehen ist.</p>
<p>hier der text:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt; 

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

const char szAppName[] = &quot;Mein erstes 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( 0, IDC_ARROW ); 
    wc.hIcon = LoadIcon( 0, IDI_APPLICATION ); 
    wc.hbrBackground = (HBRUSH) GetStockObject( WHITE_BRUSH ); 

    RegisterClass( &amp;wc ); 

    hWnd = CreateWindow( szAppName, &quot;Titelleiste&quot;, 
                        WS_OVERLAPPEDWINDOW, 
                        CW_USEDEFAULT, 
                        CW_USEDEFAULT, 
                        CW_USEDEFAULT, 
                        CW_USEDEFAULT, 
                        NULL, 
                        NULL, 
                        hInstance, 
                        NULL ); 

    ShowWindow( hWnd, SW_SHOW ); 
    UpdateWindow( hWnd ); 

    return 0; 
}
</code></pre>
<p>und wo und wie soll ich da nun noch die GetMessage() funktion einbringen.... waer also nett wenn ihr mir dabei hgelfen koennt, danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/154986/wie-erstelle-ich-ein-window</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Jul 2026 22:33:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/154986.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 Aug 2006 14:20:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 14:20:43 GMT]]></title><description><![CDATA[<p>hallo ich war mit dem problem hier schon im Borland Builder Forum dort haben wir das thema dann soweit durch gekaut das ich diese frage hier in dem forum posten soll *verwirrend grml* es geht darum das ich ein fenster zum laufen bekommen (heute angefangen hat, in Win API sich ein zuarbeiten) mein quelltext ist im soweit ausgeschrieben... doch mir wurde gesagt das die funktion GetMessage() fehlt um den &quot;leerlaufprozess&quot; zu garantieren also nur ein wisses Window zu sehen ist.</p>
<p>hier der text:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt; 

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

const char szAppName[] = &quot;Mein erstes 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( 0, IDC_ARROW ); 
    wc.hIcon = LoadIcon( 0, IDI_APPLICATION ); 
    wc.hbrBackground = (HBRUSH) GetStockObject( WHITE_BRUSH ); 

    RegisterClass( &amp;wc ); 

    hWnd = CreateWindow( szAppName, &quot;Titelleiste&quot;, 
                        WS_OVERLAPPEDWINDOW, 
                        CW_USEDEFAULT, 
                        CW_USEDEFAULT, 
                        CW_USEDEFAULT, 
                        CW_USEDEFAULT, 
                        NULL, 
                        NULL, 
                        hInstance, 
                        NULL ); 

    ShowWindow( hWnd, SW_SHOW ); 
    UpdateWindow( hWnd ); 

    return 0; 
}
</code></pre>
<p>und wo und wie soll ich da nun noch die GetMessage() funktion einbringen.... waer also nett wenn ihr mir dabei hgelfen koennt, danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108589</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108589</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Tue, 01 Aug 2006 14:20:43 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 14:39:23 GMT]]></title><description><![CDATA[<p>Das fehlt:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   switch(iMsg)
   {
      case WM_CREATE:
         break;

      case WM_COMMAND:
         switch(LOWORD(wParam))  // Switch between control IDs
         {
         }
         break;

      case WM_DESTROY:
         PostQuitMessage(0);
         break;
   }

   return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
</code></pre>
<p>Und das am Ende der WinMain:</p>
<pre><code class="language-cpp">// Message Loop
     while( GetMessage(&amp;msg, NULL, 0, 0) )
     {
           TranslateMessage(&amp;msg);
           DispatchMessage(&amp;msg);
     }
     return msg.wParam ;
</code></pre>
<p>Nimm das return(0) weg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108609</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Tue, 01 Aug 2006 14:39:23 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 14:41:28 GMT]]></title><description><![CDATA[<p>Mein Standard-Gerüst sieht folgendermaßen aus:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;commctrl.h&gt;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

// Global Variables
LPCTSTR    g_lpszAppTitle = TEXT(&quot;&lt;AppTitle&gt;&quot;);
LPCTSTR    g_lpszAppClass = TEXT(&quot;&lt;AppWindowClass&gt;&quot;);
HINSTANCE  g_hInstance;
HWND       g_hAppWindow;
//---------------------------------------------------------------------------

// Function Prototypes
VOID              RegisterAppWindow();
VOID              Create_GUI_Interface();
LRESULT CALLBACK  AppWndProc(HWND, UINT, WPARAM, LPARAM);
VOID              ShowMessage(LPCTSTR);
VOID              ShowLastErrorString();
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, int)
{
     MSG  msg;

     InitCommonControls();
     g_hInstance = hInstance;
     RegisterAppWindow();
     Create_GUI_Interface();

     // Message Loop
     while(GetMessage(&amp;msg, NULL, 0, 0))
     {
           TranslateMessage(&amp;msg);
           DispatchMessage(&amp;msg);
     }
     return msg.wParam ;
}
//---------------------------------------------------------------------------

VOID RegisterAppWindow()
{
     WNDCLASSEX wndclass;
     wndclass.cbSize        = sizeof(WNDCLASSEX);
     wndclass.style         = 0;
     wndclass.lpfnWndProc   = AppWndProc;
     wndclass.cbClsExtra    = 0;
     wndclass.cbWndExtra    = 0;
     wndclass.hInstance     = g_hInstance;
     wndclass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
     wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
     wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
     wndclass.lpszMenuName  = NULL;
     wndclass.lpszClassName = g_lpszAppClass;
     wndclass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

     RegisterClassEx(&amp;wndclass);
}
//---------------------------------------------------------------------------

VOID Create_GUI_Interface()
{
   LONG style, ex_style;

   // Create Application Window
   style = WS_VISIBLE|WS_MINIMIZEBOX|WS_SYSMENU;
   ex_style = 0;
   g_hAppWindow = CreateWindowEx(ex_style, g_lpszAppClass, g_lpszAppTitle, style,
                                 100, 100, 300, 400,
                                 NULL, NULL, g_hInstance, NULL);
}
//---------------------------------------------------------------------------

LRESULT CALLBACK AppWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   switch(iMsg)
   {
      case WM_CREATE:
         break;

      case WM_COMMAND:
         switch(LOWORD(wParam))  // Switch between control IDs
         {
         }
         break;

      case WM_DESTROY:
         PostQuitMessage(0);
         break;
   }

   return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
//---------------------------------------------------------------------------

VOID ShowMessage(LPCTSTR str)
{
   MessageBox(g_hAppWindow, str, g_lpszAppTitle,  MB_OK);
}
//---------------------------------------------------------------------------

VOID ShowLastErrorString()
{
   LPVOID lpMsgBuf;
   FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
                 FORMAT_MESSAGE_IGNORE_INSERTS,
                 NULL,
                 GetLastError(),
                 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
                 (LPTSTR) &amp;lpMsgBuf,
                 0,
                 NULL
                );
    MessageBox(g_hAppWindow, (LPCTSTR)lpMsgBuf, TEXT(&quot;Error&quot;), MB_OK | MB_ICONERROR);
    LocalFree(lpMsgBuf);
}
//---------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1108610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108610</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Tue, 01 Aug 2006 14:41:28 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 14:47:49 GMT]]></title><description><![CDATA[<p>Ach ja, du benutzt ja den BCB, nicht wahr? Eventuell ist es da noch notwendig oder ratsam, eine weitere Datei zu inkludieren nämlich</p>
<pre><code class="language-cpp">#include &lt;condefs.h&gt;
</code></pre>
<p>Das ist zumindest in meinem BCB3 vonnöten. Vielleicht ja auch in deinem BCB6.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108623</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Tue, 01 Aug 2006 14:47:49 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 15:04:43 GMT]]></title><description><![CDATA[<p>und was macht condefs.h ?</p>
<p>nur noch mal ne frage HWND = der teil worunter der name meines Prog also Window in der Win Registry reg. wird oder? also zum beispiel unter knut, dann ist mein fenster unter knut reg? bzw. das fenster was ich create wird den programm knut zugeteilt, ist das richtig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108639</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108639</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Tue, 01 Aug 2006 15:04:43 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 15:22:32 GMT]]></title><description><![CDATA[<p>T0bi schrieb:</p>
<blockquote>
<p>ist das richtig?</p>
</blockquote>
<p>nein</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108654</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108654</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Tue, 01 Aug 2006 15:22:32 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 16:53:49 GMT]]></title><description><![CDATA[<p>und wie ist es dann richtig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108719</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108719</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Tue, 01 Aug 2006 16:53:49 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 17:42:27 GMT]]></title><description><![CDATA[<p>Ein HWND (Handle to a Window) hat mit der Windows-Registry rein garnichts zu tun. Du möchtest doch sicher 'mal ein Tutorial über die WinAPI lesen!?</p>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108749</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Tue, 01 Aug 2006 17:42:27 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 20:24:45 GMT]]></title><description><![CDATA[<p>huhu swordfish *g* bin gerade dabei eins zu lesen o_O.... nun beschaeftigt mich des naechste problem ich kann jetzt nen fenster erstellen und moechte nen text drin ausgeben lassen, alles sieht so aus:</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;windows.h&gt;

LRESULT CALLBACK WinProc ( HWND, UINT, WPARAM, LPARAM );
const char szAppName[] = &quot;Meine Fenster mit Text :)&quot;;

WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{

    HWND hWnd;
    MSG messages;
    WNDCLASS wc;

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

    if( !(RegisterClass( &amp;wc ) ) )
    return 0;

    hWnd = CreateWindow( szAppName,
                         szAppName,
                         WS_OVERLAPPEDWINDOW,
                         CW_USEDEFAULT, CW_USEDEFAULT,
                         500, 300,
                         NULL, NULL,
                         hInstance,
                         NULL );

    ShowWindow( hWnd, SW_SHOW );
    UpdateWindow( hWnd );

    while( GetMessage( &amp;messages, NULL, 0, 0 ) ) {

        TranslateMessage( &amp;messages );
        DispatchMessage( &amp;messages );
    }
    return messages.wParam;
}

LRESULT CALLBACK WinPorc ( HWND hWnd, UINT messages, WPARAM wParam, LPARAM lParam ) {

        switch( messages ) {

            case WM_PAINT : {

                PAINTSTRUCT ps;
                HDC hDc;

                const char szText[] = &quot;Wer das liest is schön :P&quot;;

                hDc = BeginPaint( hWnd, &amp;ps );
                {
                    TextOut( hDc, 50, 50, szText, sizeof( szText ) - 1 );
                }
                EndPaint( hWnd, &amp;ps );
                return 0;
            }

            case WM_DESTROY : {

                PostQuitMessage( 0 );
                return 0;
            }
        }
        return DefWindowProc( hWnd, messages, wParam, lParam );
}
</code></pre>
<p>aber ich bekomm vom linker ne warnung :</p>
<pre><code>[Linker Error] Unresolved external '__stdcall WinProc(void *, unsigned int, unsigned int, long)' referenced from C:\PROGRAMME\BORLAND\CBUILDER6\PROJECTS\UNIT1.OBJ
</code></pre>
<p>was mus sich jetz tun???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108836</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Tue, 01 Aug 2006 20:24:45 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Tue, 01 Aug 2006 20:49:33 GMT]]></title><description><![CDATA[<p>Dann schau nochmal ganz genau auf deine Funktionsnamen. <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 />
Übrigens würde ich das eher so machen:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WinProc ( HWND hWnd, UINT messages, WPARAM wParam, LPARAM lParam ) 
{
    static const char szText[] = &quot;Wer das liest is schön :P&quot;;

        switch( messages ) {

            case WM_PAINT : {

                PAINTSTRUCT ps;
                HDC hDc;

                hDc = BeginPaint( hWnd, &amp;ps );
                {
                    TextOut( hDc, 50, 50, szText, sizeof( szText ) - 1 );
                }
                EndPaint( hWnd, &amp;ps );
                return 0;
            }

            case WM_DESTROY : {

                PostQuitMessage( 0 );
                return 0;
            }
        }
        return DefWindowProc( hWnd, messages, wParam, lParam );
}
</code></pre>
<p>Wozu immer wieder neu den Text definieren. Außerdem nimmt man für statische Textausgaben meist Static-Controls und schreibt nicht auf's Fenster.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108851</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108851</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Tue, 01 Aug 2006 20:49:33 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Wed, 02 Aug 2006 04:56:52 GMT]]></title><description><![CDATA[<p>T0bi schrieb:</p>
<blockquote>
<p>was mus sich jetz tun???</p>
</blockquote>
<p>Genau ein 'o' mit einem 'r' vertauschen. <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>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1108920</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1108920</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Wed, 02 Aug 2006 04:56:52 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Wed, 02 Aug 2006 10:04:11 GMT]]></title><description><![CDATA[<p>*grrrrrrrr* is mir des shcon zum 2mal in dem programm passiert hrhrhr....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1109065</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1109065</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Wed, 02 Aug 2006 10:04:11 GMT</pubDate></item><item><title><![CDATA[Reply to Wie erstelle ich ein window ???? on Fri, 04 Aug 2006 07:47:08 GMT]]></title><description><![CDATA[<p>T0bi schrieb:</p>
<blockquote>
<p>WinPorc</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /> != <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /></p>
<p>T0bi schrieb:</p>
<blockquote>
<p>WinProc</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1110328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1110328</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Fri, 04 Aug 2006 07:47:08 GMT</pubDate></item></channel></rss>