Getting a string from an edit box

I've seen numerous posts about this, but I just can't seem to wrap my brain around why this isn't working. Basically what I want to do is take the Month, Date, and Year (expressed as hEditM, hEditD, and hEditY in the code below) and pass it to my database function to complete a query based on those dates. The problem is, I get gibberish or nothing when I try to compile and run the following code:

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
case WM_CREATE:
            {
            HWND hWndButton=CreateWindowEx(NULL,
            "BUTTON",
            "Run Report",
            WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
            50,
            55,
            100,
            24,
            hwnd,
            (HMENU)NEWCUSTBOOKING,
            GetModuleHandle(NULL),
            NULL);

            hEditM=CreateWindowEx(WS_EX_CLIENTEDGE,
            "EDIT",
            "",
            WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_AUTOHSCROLL,
            55,
            25,
            25,
            25,
            hwnd,
            (HMENU)MONTH,
            GetModuleHandle(NULL),
            NULL);

            hEditD=CreateWindowEx(WS_EX_CLIENTEDGE,
            "EDIT",
            "",
            WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_AUTOHSCROLL,
            81,
            25,
            25,
            25,
            hwnd,
            (HMENU)DAY,
            GetModuleHandle(NULL),
            NULL);

            hEditY=CreateWindowEx(WS_EX_CLIENTEDGE,
            "EDIT",
            "",
            WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_AUTOHSCROLL,
            107,
            25,
            25,
            25,
            hwnd,
            (HMENU)YEAR,
            GetModuleHandle(NULL),
            NULL);

            SendMessage(hEditM,
				WM_SETTEXT,
				NULL,
				(LPARAM)"20");
            break;
            }

case WM_COMMAND:
		    {
                switch(LOWORD(wParam))
                {
                case NEWCUSTBOOKING:
                    {
                        char buffer[256];
                        SendMessage(hEditM,
                        WM_GETTEXT,
                        sizeof(buffer)/sizeof(buffer[0]),
                        reinterpret_cast<LPARAM>(buffer));
                        MessageBox(NULL,
                        buffer,
                        "Information",
                        MB_ICONINFORMATION);
                        std::cout<<*buffer;
                        rundbc();

                    }
                break;
                }
        break;
		    }


I've tried compiling with and without the -ansi flag, just to make sure it isn't a problem with unicode. I'm firing off a message box and a cout to the terminal window to see what I get. The values aren't matching so far either.
You shouldn't send a message in the WM_CREATE handler.

The problem is, I get gibberish or nothing when I try to compile
It may be gibberish to you, but it's the compiler trying to tell you what you've done wrong. If you want help with it, you need to post the messages.
Topic archived. No new replies allowed.