I borrowed a bit of code for a splitter bar in between two edits, but I'm getting weirdness when I try to either write on the bottom one or resize them by moving the bar. Often, the bottom edit disappears completely and the scrollbar dances around.

Ultimately, my goal is to have the window divided up into 5 different edits for a look similar to this:



Am I going about it the right way?

Relevant code:

HTML Code:
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    HINSTANCE   hInst;
    RECT        rect;
    static HCURSOR  hCursor;
    static BOOL bSplitterMoving;
    static DWORD    dwSplitterPos;
    static HWND hWnd1, hWnd2;

    switch (uMsg)
    {
        case WM_CREATE:
        {
            hInst = ((LPCREATESTRUCT)lParam)->hInstance;

            hWnd1 = CreateWindowEx(WS_EX_CLIENTEDGE,
                L"edit", NULL,
                WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL,
                0, 0, 0, 0,
                hWnd, (HMENU)1,
                hInst, NULL);

            hWnd2 = CreateWindowEx(WS_EX_CLIENTEDGE,
                L"edit", NULL,
                WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL,
                0, 0, 0, 0,
                hWnd, (HMENU)2,
                hInst, NULL);

            hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS));
            bSplitterMoving = FALSE;

            dwSplitterPos = 130;
HTML Code:
    case WM_SIZE:
        if ((wParam != SIZE_MINIMIZED) && (HIWORD(lParam) < dwSplitterPos))
            dwSplitterPos = HIWORD(lParam) - 10;

        /* Adjust the children's size and position */
        MoveWindow(hWnd1, 0, 0, LOWORD(lParam), dwSplitterPos - 1, TRUE);
        MoveWindow(hWnd2, 0, dwSplitterPos + 2, LOWORD(lParam), HIWORD(lParam) - dwSplitterPos - 2, TRUE);
        return 0;

    case WM_MOUSEMOVE:
        if (HIWORD(lParam) > 10) // do not allow above this mark
        {
            SetCursor(hCursor);
            if ((wParam == MK_LBUTTON) && bSplitterMoving)
            {
                GetClientRect(hWnd, &rect);
                if (HIWORD(lParam) > rect.bottom)
                    return 0;

                dwSplitterPos = HIWORD(lParam);
                SendMessage(hWnd, WM_SIZE, 0, MAKELPARAM(rect.right, rect.bottom));
            }
        }
        return 0;

    case WM_LBUTTONDOWN:
        SetCursor(hCursor);
        bSplitterMoving = TRUE;
        SetCapture(hWnd);
        return 0;


    case WM_LBUTTONUP:
        ReleaseCapture();
        bSplitterMoving = FALSE;
        return 0;
Images showing what's happening:

http://imgur.com/a/OcdSx