<?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[FENSTER Caption]]></title><description><![CDATA[<p>hi,..<br />
ich habe ein hauptfenster und ein seperates edit fenster,..<br />
eigentlich soll das edit fenster beim erstellen einen text aus einer file laden und anzeigen,..<br />
zusätzlich soll die hintergrundfarbe und die textfarbe sich ändern, schwarz als background und weiß als textfarbe,..</p>
<p>es passiert folgendes:<br />
das edit fenster lädt den text nicht,..<br />
wenn ich einen text eingebe, danach das hauptfenster anwähle erscheint der text als caption,..<br />
keine farbänderung,...</p>
<p>ich bin neu bzgl. winapi daher bitte ich um hilfe,. hier der source,..</p>
<pre><code class="language-cpp">#define STRICT
#include &lt;windows.h&gt;
#include &lt;windowsx.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ChildEdit(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:
 {
      hEdit = CreateWindow(
      &quot;edit&quot;,
      &quot;&quot;,    // &lt;- das ist der Inhalt der Editfelds
      WS_VISIBLE | WS_VSCROLL|WS_OVERLAPPEDWINDOW | ES_MULTILINE |
      ES_AUTOVSCROLL,
      0, 0, 0, 0,
      hWnd,
      NULL,
      ((LPCREATESTRUCT) lParam) -&gt; hInstance,
      NULL);
      return 0;
 }
 case WM_SIZE:
 {
      MoveWindow(hEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
      return 0;
 }
 case WM_CLOSE:
 {
      DestroyWindow(hWnd);
      return 0;
 }
 case WM_DESTROY:
 {
      PostQuitMessage(0);
      return 0;
 }
 }
    return DefWindowProc(hWnd, message, wParam, lParam);
}

LRESULT CALLBACK ChildEdit(HWND hEdit, UINT message, WPARAM wparam, LPARAM lparam)
{
 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 = (char*) malloc(iFileSize);

                fseek(fz, 0, SEEK_SET);
                fread(buffer, 1, iFileSize, fz);
                fclose(fz);
            }
            SendMessage (hEdit, WM_SETTEXT, (WPARAM) FALSE, (LPARAM) buffer); 
            free(buffer);
           HDC hdc;
            PAINTSTRUCT ps;
            hdc=BeginPaint(hEdit,&amp;ps);
            {            
             SetTextColor(hdc,RGB(255,255,0));
             SetBkColor(hdc,RGB(0,0,0));
             }
             EndPaint(hEdit,&amp;ps); 

   return 0;
  }

  case WM_CLOSE:
  {
       FILE *fz;
            char *buffer = NULL;
            int iLength;

            iLength = GetWindowTextLength(hEdit);

            buffer = (char*)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(hEdit);
            return 0;
  }

  case WM_PAINT:
  {
   HDC hdc;
            PAINTSTRUCT ps;
            hdc=BeginPaint(hEdit,&amp;ps);
            {            
             SetTextColor(hdc,RGB(255,255,0));
             SetBkColor(hdc,RGB(0,0,0));
             }
             EndPaint(hEdit,&amp;ps); 

   return 0;  
   }

case WM_DESTROY:
        {
            PostQuitMessage(0);
            return 0;
        }
    }
    return DefWindowProc(hEdit, message, wparam, lparam);
}
</code></pre>
<p>danke für potentielle hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/200259/fenster-caption</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 15:50:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/200259.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Dec 2007 17:16:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to FENSTER Caption on Wed, 12 Dec 2007 17:16:00 GMT]]></title><description><![CDATA[<p>hi,..<br />
ich habe ein hauptfenster und ein seperates edit fenster,..<br />
eigentlich soll das edit fenster beim erstellen einen text aus einer file laden und anzeigen,..<br />
zusätzlich soll die hintergrundfarbe und die textfarbe sich ändern, schwarz als background und weiß als textfarbe,..</p>
<p>es passiert folgendes:<br />
das edit fenster lädt den text nicht,..<br />
wenn ich einen text eingebe, danach das hauptfenster anwähle erscheint der text als caption,..<br />
keine farbänderung,...</p>
<p>ich bin neu bzgl. winapi daher bitte ich um hilfe,. hier der source,..</p>
<pre><code class="language-cpp">#define STRICT
#include &lt;windows.h&gt;
#include &lt;windowsx.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ChildEdit(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:
 {
      hEdit = CreateWindow(
      &quot;edit&quot;,
      &quot;&quot;,    // &lt;- das ist der Inhalt der Editfelds
      WS_VISIBLE | WS_VSCROLL|WS_OVERLAPPEDWINDOW | ES_MULTILINE |
      ES_AUTOVSCROLL,
      0, 0, 0, 0,
      hWnd,
      NULL,
      ((LPCREATESTRUCT) lParam) -&gt; hInstance,
      NULL);
      return 0;
 }
 case WM_SIZE:
 {
      MoveWindow(hEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
      return 0;
 }
 case WM_CLOSE:
 {
      DestroyWindow(hWnd);
      return 0;
 }
 case WM_DESTROY:
 {
      PostQuitMessage(0);
      return 0;
 }
 }
    return DefWindowProc(hWnd, message, wParam, lParam);
}

LRESULT CALLBACK ChildEdit(HWND hEdit, UINT message, WPARAM wparam, LPARAM lparam)
{
 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 = (char*) malloc(iFileSize);

                fseek(fz, 0, SEEK_SET);
                fread(buffer, 1, iFileSize, fz);
                fclose(fz);
            }
            SendMessage (hEdit, WM_SETTEXT, (WPARAM) FALSE, (LPARAM) buffer); 
            free(buffer);
           HDC hdc;
            PAINTSTRUCT ps;
            hdc=BeginPaint(hEdit,&amp;ps);
            {            
             SetTextColor(hdc,RGB(255,255,0));
             SetBkColor(hdc,RGB(0,0,0));
             }
             EndPaint(hEdit,&amp;ps); 

   return 0;
  }

  case WM_CLOSE:
  {
       FILE *fz;
            char *buffer = NULL;
            int iLength;

            iLength = GetWindowTextLength(hEdit);

            buffer = (char*)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(hEdit);
            return 0;
  }

  case WM_PAINT:
  {
   HDC hdc;
            PAINTSTRUCT ps;
            hdc=BeginPaint(hEdit,&amp;ps);
            {            
             SetTextColor(hdc,RGB(255,255,0));
             SetBkColor(hdc,RGB(0,0,0));
             }
             EndPaint(hEdit,&amp;ps); 

   return 0;  
   }

case WM_DESTROY:
        {
            PostQuitMessage(0);
            return 0;
        }
    }
    return DefWindowProc(hEdit, message, wparam, lparam);
}
</code></pre>
<p>danke für potentielle hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1419520</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1419520</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Wed, 12 Dec 2007 17:16:00 GMT</pubDate></item></channel></rss>