SetWindowText(evento, char);

SetWindowText(evento, char);
#if defined(UNICODE) && !defined(_UNICODE)
    #define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
    #define UNICODE
#endif

#include <tchar.h>
#include <windows.h>
#include <math.h>

#define ID_BUTTON  1

static HWND num1, num2, t;


/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");

int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND       hwnd;       /** Evento de Janela */
    MSG        messages;   /*Here messages to the application are saved*/
    WNDCLASSEX wincl;      /** Dados e struturas para Classe de Janela */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;
    wincl.style = CS_DBLCLKS;             /** Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_EXCLAMATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_EXCLAMATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;       /**Estrutura ou Instancia da Janela*/
    wincl.hbrBackground = GetSysColorBrush(COLOR_3DFACE);

    /**Register the window class, and if it fails quit the program*/
    if (!RegisterClassEx (&wincl))
        return 0;



    /**Veja a Diferença entre CreateWindow e CreateWindowEx*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /** Nome da Classe */
           _T("Raiz Quadrada"), /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /*where the window ends up on the screen*/
           500,                 /** Largura do Programa */
           200,                 /** Altura em pixels */
           HWND_DESKTOP,        /*The window is a child-window to desktop*/
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /** Nenhum dado de Criação da janela */
    );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    while (GetMessage (&messages, NULL, 0, 0))
    {
        /**Translate virtual-key messages into character messages*/
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }
    return messages.wParam;
}


LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message,
                                  WPARAM wParam, LPARAM lParam) {
    switch (message) {
        case WM_CREATE:
            CreateWindow(
                TEXT("static"),
                TEXT("Cálculo da Raiz Quadrada"),
                WS_VISIBLE | WS_CHILD,
                30, 20, 480, 20,
                hwnd, NULL, NULL, NULL
            );

            num1 = CreateWindow(
                TEXT("edit"), TEXT(""), WS_VISIBLE |
                                WS_CHILD | WS_BORDER,
                30, 50, 80, 20,
                hwnd, NULL, NULL, NULL
            );

            num2 = CreateWindow(
                TEXT("edit"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_BORDER,
                120, 50, 80, 20,
                hwnd, NULL, NULL, NULL
            );

            CreateWindow(
                TEXT("button"), TEXT("Calcular"), WS_VISIBLE |
                         WS_CHILD | WS_BORDER,
                220, 50, 80, 20,
                hwnd, (HMENU) ID_BUTTON, NULL, NULL
            );

            CreateWindow(
                TEXT("static"), TEXT("https://cgllp-mz.blogspot.com"),
                WS_VISIBLE | WS_CHILD,
                30, 90, 280, 20,
                hwnd, NULL, NULL, NULL
            );
            t = CreateWindow(
                TEXT("edit"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_BORDER,
                320, 50, 80, 20,
                hwnd, NULL, NULL, NULL
            );
            break;

        case WM_COMMAND:
            if(LOWORD(wParam)==ID_BUTTON) {
                int n1 = GetWindowTextLength(num1)+1;
                int n2 = GetWindowTextLength(num2)+1;
                static char t1[40];
                static char t2[40];
                GetWindowText(num1, t1, n1);
                GetWindowText(num2, t2, n2);
                int res = atoi(t1)+atoi(t2); /**Resultado da Soma*/

                float raiz = sqrt(atof(t2)); /**Square Root*/
                char tam2[40];
                itoa(raiz, tam2, 10);       /**itoa = int to ascii*/

                char tam[40];
                itoa(res, tam, 10); /**Converte inteiro para String*/

                //MessageBox(NULL, tam2, "Resultado: ", MB_OK);

                SetWindowText(t, tam2);
                return 0;
            }
            break;

        case WM_DESTROY:
            PostQuitMessage(0); /** Saída padrão do Sistema */
            break;
        default:                /**for messages that we don't deal with*/
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

Comentários