#include "eduwin.h"

static HWND g_slider;
static HWND g_progress;
static HWND g_label;

static void on_update(void *data)
{
    int pos = slider_get_pos(g_slider);
    set_progress(g_progress, pos);

    WCHAR buf[32];
    swprintf(buf, 32, L"当前值：%d", pos);
    set_text(g_label, buf);
}

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

    HWND win = create_window(L"滑块与进度条演示", 420, 280);
    if (!win)
    {
        alert(L"错误", L"创建窗口失败");
        return 1;
    }

    create_label(win, L"滑块（拖动调节）：", 20, 20, 160, 22);
    g_slider = create_slider(win, 20, 48, 370, 30);
    slider_set_pos(g_slider, 30);

    create_label(win, L"进度条：", 20, 90, 160, 22);
    g_progress = create_progressbar(win, 20, 118, 370, 24);
    set_progress(g_progress, 30);

    g_label = create_label(win, L"当前值：30", 20, 160, 200, 22);

    HWND btn = create_button(win, L"读取滑块值 → 更新进度条", 100, 200, 220, 30);
    on_button_click(btn, on_update, NULL);

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