Help with a program?

So, I am just making something to work with textfields, and am having some trouble. The program is where you enter in your name in an edit box, click a button, and it says "Hello, <whatever you typed in>". Well, I can't save the text entered into the edit box and display it. Once you click the button it just displays a blank child static window. Any help?
My code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    case WM_CREATE:
    {
        CreateWindowEx(WS_EX_CLIENTEDGE, L"BUTTON", L"Hello.",
                       WS_CHILD | WS_VISIBLE,
                       20, 120, 60, 40,
                       hwnd, (HMENU)2, NULL, NULL);
        CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
                       WS_CHILD | WS_VISIBLE,
                       120, 40, 100, 30, hwnd, (HMENU)IDC_TEXT, NULL, NULL);
        HWND hEdit = GetDlgItem(hwnd, IDC_TEXT);
        LPWSTR buf;
        GetWindowText(hEdit, buf, 511);
        break;
    }
    case WM_COMMAND:
        switch(LOWORD(wParam)){
        case 2:
            CreateWindowEx(WS_EX_CLIENTEDGE, L"STATIC", L"What do I put here?",
                           WS_VISIBLE | WS_CHILD,
                           20, 200, 300, 40, hwnd, NULL, NULL, NULL);
        }
    }


And I defined IDC_TEXT at the top as 101:
#define IDC_TEXT 101

So, My question is... How do I get the static window to show the text the user entered? Please help, because I am pretty sure I will have to know this in order to be a software developer
You need to allocate the buffer yourself before calling GetWindowText()...

WCHAR buf[511];
Okay, well, I am using Qt because my CodeBlocks compiler doesn't have any of the recent winapi functions. Qt makes me make the buffer as a LPWSTR. Does that have any impact on it?
Topic archived. No new replies allowed.