C++: Convert Win32 textbox input into ASCII integers, do some math, convert back into characters that can be printed in another Win32 textbox : This is hopefully, someday, going to be an encryption program. I decided to get fancy and make a window with two text boxes and two buttons; one text box for input, one text box for output, one button for encryption, one button for decryption. I'm using text boxes because unfortunately, a user can't copy and paste out of message boxes, and nobody wants to memorize or write down 200 pairs of numbers. My current problem is with getting the correct data type conversions happening before and after I do the math. My IDE is Code::Blocks, my compiler is GNU GCC.

This first part is basically just initial setup.

    #if defined(UNICODE) && !defined(_UNICODE)
        #define _UNICODE
    #elif defined(_UNICODE) && !defined(UNICODE)
        #define UNICODE
    #endif

    #include <iostream>
    #include <windows.h>
    #include <tchar.h>
    #define ID_BTNENCRYPT 1
    #define ID_TXTMSG 2
    #define ID_TXTRTN 3
    #define ID_BTNDECRYPT 4

    const char g_szClassName[] = "MyWindowClass";

    HWND button;
    HWND button2;
    HWND textbox;
    HWND textreturn;

    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { 
    //Creates buttons and text boxes
    switch(msg) {
        case WM_CREATE: {
            button = CreateWindow("button",
                                  "Encrypt Message",
                                  WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
                                  240, 560,
                                  200, 30,
                                  hwnd, (HMENU) ID_BTNENCRYPT, GetModuleHandle(NULL), NULL);
            button2 = CreateWindow("button",
                                  "Decrypt Message",
                                  WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
                                  240, 600,
                                  200, 30,
                                  hwnd, (HMENU) ID_BTNDECRYPT, GetModuleHandle(NULL), NULL);
            textbox = CreateWindow("EDIT",
                                    "Enter your message here:",
                                    WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL,
                                    30, 30, 620, 270,
                                    hwnd, (HMENU) ID_TXTMSG, GetModuleHandle(NULL), NULL);
            textreturn = CreateWindow("EDIT",
                                     "",
                                     WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL | ES_MULTILINE,
                                     30, 310, 620, 200,
                                     hwnd, (HMENU) ID_TXTRTN, GetModuleHandle(NULL), NULL);

            break;
        }
        case WM_COMMAND: { //Executes commands upon the clicking of buttons
            switch (LOWORD(wParam)){
First button. I want to take text input through a text box, change the characters to integers, do fun math with my integers, and put them back into a char array to be printed in another text box.

                case ID_BTNENCRYPT: { 

                    int len = GetWindowTextLength(textbox) + 1;
                    char* text = new char[len];
                    GetWindowText(textbox, &text[0], len);

I don't know why this does not work    
    
    int x = 0;
    int INTmessage[len];
    int ENClen = (len * 2);
    char *ENCmessage = new char[ENClen];

    while (x < len) {
        INTmessage[x] = int(&text[x]) - 32;
        x++;
    }

    int z = 0;
    int y = 0;


    while (z < ENClen) { 
I figure it has something to do with how I'm calling ENCmessage. I know that it should be &ENCmessage but &BlahBlahBlah can't go on the left side of the equal sign.
        
        ENCmessage[z] = char(INTmessage[y] % 9);
        ENCmessage[z + 1] = char(INTmessage[y] % 10);

        z += 2;
        y++;
    }

    /*int w = 0; //This stuff didn't work, ignore it.
    //char *textx = new char[ENClen];
    char *ltr = new char[ENClen];

    while (w < ENClen) {
        ltr[w] = (ENCmessage[w]);
        w++;
    }*/



                    SetWindowText(textreturn, "");
                    SetWindowText(textreturn, &ENCmessage[0]);

I wish this output what I want it to but I get a bunch of very strange symbols, and get different symbols each time I run the same text through.




                    ::MessageBox(hwnd, "Message Encrypted", "SUCCESS!", MB_OK);
                }
            }
            switch (LOWORD(wParam)){
                case ID_BTNDECRYPT: { //This is a whole different party for a different time.

                    int len = GetWindowTextLength(textbox) + 1;
                    char* text = new char[len];
                    GetWindowText(textbox, &text[0], len);


                    ::MessageBox(hwnd, "Message Decrypted", "SUCCESS!", MB_OK);
                }
            }
            break;
        }
        case WM_CLOSE:
            DestroyWindow(hwnd);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);

    }

    return 0;
    }
Here is my window creation if you need to see it.

    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    FreeConsole();

    WNDCLASSEX wc;
    HWND hwnd;
    MSG Msg;

    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = 0;
    wc.lpfnWndProc = WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH) (COLOR_WINDOW - 2);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = g_szClassName;
    if (!RegisterClassEx(&wc)) {
        ::MessageBox(NULL, "Window Registration Status: Hopelessly F***ed", "", MB_OK);
        return 0;
    }

    hwnd = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        g_szClassName,
        "enCRPEtion: Free Encryption Software",
        WS_OVERLAPPEDWINDOW,
        0, 0,
        700, 700,
        NULL, NULL, hInstance, NULL);

    if (hwnd == NULL) {
        ::MessageBox(NULL,"Window Creation Status: Gone to $h!t", "", MB_OK);
    }

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    while(GetMessage(&Msg, NULL, 0, 0) > 0) {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }

    return Msg.wParam;
    }
