<?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[VSCROLL und edit]]></title><description><![CDATA[<p>hi leutz,<br />
ich habe ein kleines problem, ich bin auch neu, was mit winapi zu tun hat,..<br />
also ich habe zwo edit controlls, wenn das eine vertical scrolled soll das andere auch scrollen,..</p>
<p>also ich verarbeite EM_SCROLL in dem einen fenster und schicke eine nachricht ans andere das auch scollen soll,.. wird das automatisch dann durch DefWindowProc() verarbeitet oder muss das denn auch manuell gemacht werden??<br />
hier mal 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;
#include &lt;string&gt;
using namespace std;
static LONG_PTR PrevWndProcEdit;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK WndConsole(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK EditWndProc (HWND , UINT , WPARAM , LPARAM );
static HWND hEdit,hOffset;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
    HWND     hWnd,hConsole;
    MSG      msg;
    WNDCLASS wcmain;
    WNDCLASS wcconsole;

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

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

    RegisterClass(&amp;wcmain);

    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);
    const char szConsoleName[] = &quot;Console&quot;;
    wcconsole.style          = CS_HREDRAW | CS_VREDRAW;
    wcconsole.lpfnWndProc    = WndConsole;
    wcconsole.cbClsExtra     = 0;
    wcconsole.cbWndExtra     = 0;
    wcconsole.hInstance      = hInstance;
    wcconsole.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
    wcconsole.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcconsole.hbrBackground  = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
    wcconsole.lpszMenuName   = NULL;
    wcconsole.lpszClassName  = szConsoleName;
    RegisterClass(&amp;wcconsole);
    hConsole = CreateWindow( szConsoleName,
                         szConsoleName,
                         WS_OVERLAPPEDWINDOW,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         NULL,
                         NULL,
                         hInstance,
                         NULL );
    ShowWindow(hConsole, iCmdShow);
    UpdateWindow(hConsole);

    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_CREATE:
 {

      return 0;
 }
 case WM_SIZE:
 {

      return 0;
 }
 case WM_CLOSE:
 {
      SendMessage(FindWindow(&quot;Console&quot;,&quot;Console&quot;),WM_CLOSE,(WPARAM)0,(LPARAM)0);
      DestroyWindow(hWnd);
      return 0;
 }
 case WM_DESTROY:
 {
      PostQuitMessage(0);
      return 0;
 }

 }
    return DefWindowProc(hWnd, message, wParam, lParam);
}

LRESULT CALLBACK WndConsole(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    switch(message)
    {
    case WM_CREATE:
        {            FILE *fz;
            char *buffer = NULL;
            string buffer2=&quot;1\r2\r3\r4\r5\r6\r7\r8\r\0&quot;;

			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);
            }

              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,
                                   51, 0, 400, 400,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);
              hOffset = CreateWindowEx(WS_EX_CLIENTEDGE,
                                   &quot;edit&quot;,
                                   &quot;1\r2\r3\r4\r5\r6\r7\r8\r\0&quot;,    // &lt;- das ist der Inhalt der Editfelds
                                   WS_CHILD | WS_VISIBLE | ES_MULTILINE |
                                              ES_AUTOVSCROLL,
                                   0, 0, 50, 400,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);
                 PrevWndProcEdit = SetWindowLongPtr (hEdit, GWLP_WNDPROC, 
                                (LONG_PTR) EditWndProc);       
            free(buffer);

            return 0;
        }
    case WM_SIZE:
        {MoveWindow(hEdit, 51, 0, 400,400, TRUE);
        UpdateWindow(hEdit);
            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(hWnd);
            return 0;
        }
    case WM_DESTROY:
        {
            PostQuitMessage(0);
            return 0;
        }
    case WM_PAINT:
         {
        //SetBkColor((HDC)wParam,RGB(0,0,0));         // Texthintergrund auf transparent setzen
        //SetTextColor((HDC)wParam,RGB(255,255,255)); // Textfarbe auf Weiss setzen
        return 0;//(long)CreateSolidBrush(RGB(0,0,0)); 
         }

    case WM_CTLCOLOREDIT:
         {
        SetBkColor((HDC)wParam,RGB(0,0,0));         // Texthintergrund auf transparent setzen
        SetTextColor((HDC)wParam,RGB(255,255,255)); // Textfarbe auf Weiss setzen
        return (long)CreateSolidBrush(RGB(0,0,0)); 
         }
    case WM_CTLCOLORSTATIC:
         {
        SetBkColor((HDC)wParam,RGB(0,0,0));         // Texthintergrund auf transparent setzen
        SetTextColor((HDC)wParam,RGB(255,255,255)); // Textfarbe auf Weiss setzen
        return (long)CreateSolidBrush(RGB(0,0,0)); 
         }
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}
LRESULT CALLBACK EditWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)
   {
      case EM_SCROLL:
        {SendMessage(hOffset,EM_SCROLL,wParam,(LPARAM) 0);
         break;  
		 }
   }

return CallWindowProc ((WNDPROC) PrevWndProcEdit, hwnd, message, wParam, lParam);
}
</code></pre>
<p>danke für eure hilfe...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/200741/vscroll-und-edit</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 13:04:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/200741.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Dec 2007 10:48:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to VSCROLL und edit on Wed, 19 Dec 2007 10:48:43 GMT]]></title><description><![CDATA[<p>hi leutz,<br />
ich habe ein kleines problem, ich bin auch neu, was mit winapi zu tun hat,..<br />
also ich habe zwo edit controlls, wenn das eine vertical scrolled soll das andere auch scrollen,..</p>
<p>also ich verarbeite EM_SCROLL in dem einen fenster und schicke eine nachricht ans andere das auch scollen soll,.. wird das automatisch dann durch DefWindowProc() verarbeitet oder muss das denn auch manuell gemacht werden??<br />
hier mal 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;
#include &lt;string&gt;
using namespace std;
static LONG_PTR PrevWndProcEdit;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK WndConsole(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK EditWndProc (HWND , UINT , WPARAM , LPARAM );
static HWND hEdit,hOffset;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
    HWND     hWnd,hConsole;
    MSG      msg;
    WNDCLASS wcmain;
    WNDCLASS wcconsole;

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

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

    RegisterClass(&amp;wcmain);

    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);
    const char szConsoleName[] = &quot;Console&quot;;
    wcconsole.style          = CS_HREDRAW | CS_VREDRAW;
    wcconsole.lpfnWndProc    = WndConsole;
    wcconsole.cbClsExtra     = 0;
    wcconsole.cbWndExtra     = 0;
    wcconsole.hInstance      = hInstance;
    wcconsole.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
    wcconsole.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcconsole.hbrBackground  = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
    wcconsole.lpszMenuName   = NULL;
    wcconsole.lpszClassName  = szConsoleName;
    RegisterClass(&amp;wcconsole);
    hConsole = CreateWindow( szConsoleName,
                         szConsoleName,
                         WS_OVERLAPPEDWINDOW,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         NULL,
                         NULL,
                         hInstance,
                         NULL );
    ShowWindow(hConsole, iCmdShow);
    UpdateWindow(hConsole);

    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_CREATE:
 {

      return 0;
 }
 case WM_SIZE:
 {

      return 0;
 }
 case WM_CLOSE:
 {
      SendMessage(FindWindow(&quot;Console&quot;,&quot;Console&quot;),WM_CLOSE,(WPARAM)0,(LPARAM)0);
      DestroyWindow(hWnd);
      return 0;
 }
 case WM_DESTROY:
 {
      PostQuitMessage(0);
      return 0;
 }

 }
    return DefWindowProc(hWnd, message, wParam, lParam);
}

LRESULT CALLBACK WndConsole(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    switch(message)
    {
    case WM_CREATE:
        {            FILE *fz;
            char *buffer = NULL;
            string buffer2=&quot;1\r2\r3\r4\r5\r6\r7\r8\r\0&quot;;

			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);
            }

              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,
                                   51, 0, 400, 400,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);
              hOffset = CreateWindowEx(WS_EX_CLIENTEDGE,
                                   &quot;edit&quot;,
                                   &quot;1\r2\r3\r4\r5\r6\r7\r8\r\0&quot;,    // &lt;- das ist der Inhalt der Editfelds
                                   WS_CHILD | WS_VISIBLE | ES_MULTILINE |
                                              ES_AUTOVSCROLL,
                                   0, 0, 50, 400,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);
                 PrevWndProcEdit = SetWindowLongPtr (hEdit, GWLP_WNDPROC, 
                                (LONG_PTR) EditWndProc);       
            free(buffer);

            return 0;
        }
    case WM_SIZE:
        {MoveWindow(hEdit, 51, 0, 400,400, TRUE);
        UpdateWindow(hEdit);
            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(hWnd);
            return 0;
        }
    case WM_DESTROY:
        {
            PostQuitMessage(0);
            return 0;
        }
    case WM_PAINT:
         {
        //SetBkColor((HDC)wParam,RGB(0,0,0));         // Texthintergrund auf transparent setzen
        //SetTextColor((HDC)wParam,RGB(255,255,255)); // Textfarbe auf Weiss setzen
        return 0;//(long)CreateSolidBrush(RGB(0,0,0)); 
         }

    case WM_CTLCOLOREDIT:
         {
        SetBkColor((HDC)wParam,RGB(0,0,0));         // Texthintergrund auf transparent setzen
        SetTextColor((HDC)wParam,RGB(255,255,255)); // Textfarbe auf Weiss setzen
        return (long)CreateSolidBrush(RGB(0,0,0)); 
         }
    case WM_CTLCOLORSTATIC:
         {
        SetBkColor((HDC)wParam,RGB(0,0,0));         // Texthintergrund auf transparent setzen
        SetTextColor((HDC)wParam,RGB(255,255,255)); // Textfarbe auf Weiss setzen
        return (long)CreateSolidBrush(RGB(0,0,0)); 
         }
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}
LRESULT CALLBACK EditWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)
   {
      case EM_SCROLL:
        {SendMessage(hOffset,EM_SCROLL,wParam,(LPARAM) 0);
         break;  
		 }
   }

return CallWindowProc ((WNDPROC) PrevWndProcEdit, hwnd, message, wParam, lParam);
}
</code></pre>
<p>danke für eure hilfe...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423039</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423039</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Wed, 19 Dec 2007 10:48:43 GMT</pubDate></item></channel></rss>