Problem with the text box..

Well I solved the problem with the output text and change the static to an edit read only text box. Now I can see the message and the scrolls are functioning.. The problem is that, when I start to scroll the text inside the box has a strange behavior.. like unreadable .. is like you paint something and the hole text inside leaves traces and in the end all edit area became black. And that happens only if I set the edit box to ES_READONLY.
Can someone help me understand what I'm doing wrong..?
Here is the code again

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.
..
void LoadFileInResource(int name, int type, DWORD& size, const char*& data)
{
    HMODULE handle = ::GetModuleHandle(NULL);
    HRSRC rc       = ::FindResource(handle, MAKEINTRESOURCE(name), MAKEINTRESOURCE(type));
    HGLOBAL rcData = ::LoadResource(handle, rc);
    size           = ::SizeofResource(handle, rc);
    data           = static_cast <const char*>(::LockResource(rcData));
}
void editWindow(HWND hWnd)
{
    hEdit = CreateWindowW(L"edit", NULL,
                  WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
                          706, 123, 355, 411, hWnd, NULL, NULL, NULL);
}
case WM_COMMAND:
	switch(wp)
	{
		case IDCH_BOX1:
                    {
                    DWORD size = 0;
                    const char* data = NULL;
                    LoadFileInResource(IDR_MYTEXT, TEXTFILE, size, data);
                    SendMessage((HWND)hEdit, WM_SETTEXT, 0, (LPARAM)data);
                    return DefWindowProc(hWnd, msg, wp, lp);
                    }
		default:
			return DefWindowProc(hWnd, msg, wp, lp);
	}
}
Last edited on
ohhhhh ok ok

Here it is the problem I just got in to the hole code again and I had this

1
2
3
4
5
6
7
8
9
10
11
case WM_CTLCOLORSTATIC: // Text color and background of the static control
            {
                HDC hdcStatic = (HDC)wp;
                SetTextColor(hdcStatic, RGB(0, 0, 0));
                SetBkMode(hdcStatic, TRANSPARENT);
                if(hbrBkgnd == NULL)
                {
                    hbrBkgnd = CreateSolidBrush(RGB(0, 0, 0));
                }
                return (INT_PTR)(HBRUSH)GetStockObject(NULL_BRUSH);
            }


I just only remove the WM_CTLCOLORSTATIC to see if this cause the problem .. and YES
Now I just need how to make background Transparent for the edit box, because the DefWindowProc always will return the default background and text color..
Is the WM_CTLCOLOREDIT same syntax as is for CTLCOLORSTATIC ?
Hmmm the edit control that is set to disabled or Read only they send the same WM_CTLCOLORSTATIC message.

So how can I change this:
1
2
3
4
5
6
7
8
9
10
11
case WM_CTLCOLORSTATIC: // Text color and background of the Read Only control
            {
                HDC hdcStatic = (HDC)wp;
                SetTextColor(hdcStatic, RGB(0, 0, 0));
                SetBkMode(hdcStatic, TRANSPARENT);
                if(hbrBkgnd == NULL)
                {
                    hbrBkgnd = CreateSolidBrush(RGB(0, 0, 0));
                }
                return (INT_PTR)(HBRUSH)GetStockObject(NULL_BRUSH);
            }

to work fine with my edit control read only ?
Topic archived. No new replies allowed.