Esse programa usa a função GetWindowTextA para recuperar o título da janela - Post reescrito em 02/09/2023

main.html
#include <windows.h>

#define BTN_BUSCA 1

void Controles(HWND);

static HWND r;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lParam) {
    switch(msg) {
        case WM_CREATE:
            Controles(hwnd);
            return 0;
        case WM_COMMAND:
            if(LOWORD(wP)==BTN_BUSCA) {
            	static char titulo[50];
                GetWindowTextA(hwnd, titulo, 30);
                SetWindowText(r, titulo);
            }
            return 0;
        /* Upon destruction, tell the main thread to stop */
        case WM_DESTROY: {
            PostQuitMessage(0);
            break;
        }
		
        default:
            return DefWindowProc(hwnd, msg, wP, lParam);
    }
    return 0;
}

void Controles(HWND hwnd) {
    CreateWindow(
        TEXT("button"),TEXT("Título do Aplicativo"),
        WS_VISIBLE | WS_CHILD | WS_BORDER,
        20, 70, 140, 20,
        hwnd, (HMENU) BTN_BUSCA, NULL, NULL
    );
    r = CreateWindow(
        TEXT("edit"), TEXT(""),WS_VISIBLE|WS_CHILD|WS_DISABLED,
        180, 70, 200, 20,
        hwnd, NULL, NULL, NULL
    );
}

int WINAPI WinMain(HINSTANCE hI, HINSTANCE hPI, LPSTR lpCmdLine, int iCS) {
    WNDCLASSEX wc; /* A properties struct of our window */
    HWND hwnd; /* A 'HANDLE', hence the H, or a pointer to our window */
    MSG msg; /* A temporary location for all messages */

    memset(&wc,0,sizeof(wc));
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.lpfnWndProc   = WndProc; /* This is where we will send messages to */
    wc.hInstance     = hI;
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = GetSysColorBrush(COLOR_WINDOWFRAME);
    wc.lpszClassName = "WindowClass";
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

    if(!RegisterClassEx(&wc)) {
        MessageBox(
            NULL, "Window Registration Failed!",
            "Error!", MB_ICONEXCLAMATION | MB_OK
        );
        return 0;
    }

    hwnd = CreateWindowEx(
        WS_EX_CLIENTEDGE, "WindowClass", "Programação para Windows",
        WS_VISIBLE | WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, /* x */
        CW_USEDEFAULT, /* y */
        425, /* width */
        210, /* height */
        NULL, NULL, hI, NULL
    );

    if(hwnd == NULL) {
        MessageBox(
            NULL, "Window Creation Failed!",
            "Error!", MB_ICONEXCLAMATION | MB_OK
        );
        return 0;
    }

    while(GetMessage(&msg, NULL, 0, 0) > 0) {
        TranslateMessage(&msg);
        DispatchMessage(&msg); /* Send it to WndProc */
    }
    return msg.wParam;
}

Comentários