how can i change the text and backcolor on a window?

i never understanded these :(
how can i change the text and backcolor on a window?
i use the WM_CTLCOLORSTATIC,WM_CTLCOLOREDIT handlers, but they seem be ginored :(
what i'm doing wrong? :(
did i miss any style?
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class consolewindow
{
    WNDPROC wpOrigEditProc;
    form frmconsolewindow{"Console"};
    HWND consoleedit=NULL;
    static LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        consolewindow *clwindow=(consolewindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
        static HBRUSH brush=(HBRUSH)GetStockObject(BLACK_BRUSH);
        switch (message)                  /* handle the messages */
        {
            case WM_CTLCOLORSTATIC:
            case WM_CTLCOLOREDIT:
            {
                SetBkMode((HDC)wParam,TRANSPARENT);
                return (LRESULT)brush;
            }
            break;
            case WM_DESTROY:
                //PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                SetWindowLong(clwindow->consoleedit, GWL_WNDPROC,
                (LONG) clwindow->wpOrigEditProc);
                break;

        }

        return CallWindowProc (clwindow->wpOrigEditProc,hwnd, message, wParam, lParam);
    }
public:
    consolewindow(string strTitle)
    {
        frmconsolewindow.Text=strTitle;
        consoleedit = CreateWindow("Edit", "hello editor",
                   WS_CHILD | WS_VISIBLE | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL| ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, 0, 0,
                   frmconsolewindow.width-20, frmconsolewindow.height -40 , frmconsolewindow, 0, GetModuleHandle(0), 0 ) ;
        if(consoleedit==NULL)
        SetBkColor(GetDC(consoleedit),RGB(0,0,0));
        SetTextColor(GetDC(consoleedit), RGB(0,0,0));
        wpOrigEditProc = (WNDPROC)SetWindowLong(consoleedit,GWL_WNDPROC,(LONG)consolewindow::WindowProcedure);
        SetWindowLong(consoleedit,GWL_USERDATA,(LONG)this);
        SetClassLong(consoleedit,GCL_HBRBACKGROUND,(LONG)CreateSolidBrush(RGB(255, 255, 255)));


    }
};
Last edited on
Just off the top of my head and can think of two things you could immediately do to help your situation...

1) Stop writing obfuscating code by wrapping absolutely everything you do in abstractions and classes...

https://en.wikipedia.org/wiki/Obfuscation_%28software%29

2) Look at this post...

http://www.cplusplus.com/forum/windows/176612/


Topic archived. No new replies allowed.