#include "eduwin.h"

static HWND text;   /* 文本框 */
static HWND label;  /* 标签 */

/* 点击按钮时，把文本框内容显示到标签上 */
static void on_click(void *data)
{
    const WCHAR *s = get_text(text);
    set_text(label, s);
    set_text(text, L"");
}

int main(void)
{
    if (init_app() != 0)
    {
        alert(L"错误", L"eduwin 初始化失败");
        return 1;
    }

    HWND win = create_window(L"Hello eduwin", 400, 200);
    if (!win)
    {
        alert(L"错误", L"创建窗口失败");
        return 1;
    }

    /* 文本框 */
    text = create_text(win, L"请输入文字", 20, 20, 250, 24);

    /* 按钮 */
    HWND btn = create_button(win, L"显示", 280, 20, 80, 24);

    /* 标签（用来显示输入的文字） */
    label = create_label(win, L"", 20, 60, 340, 80);

    on_button_click(btn, on_click, NULL);

    show_window(win);
    run_app();
    return 0;
}
