- Before you start
- Windows x64, C SDK, CMake and MSVC
- What you will build
- Build and edit a window driven by C
Run the packaged app
Run this from the C SDK root. The window closes after four seconds by default; 0 keeps it open until you close it. Check the heading and changing tick count.
.\bin\kui_c_example_window_demo.exe 0Build only this example
The packaged examples/CMakeLists.txt links KuiC::C and copies runtime DLLs. Configure once, then build window_demo alone.
cmake -S examples -B build-c-examples -A x64 "-DKuiC_DIR=$PWD/cmake"
cmake --build build-c-examples --config Release --target kui_c_example_window_demo
.\build-c-examples\Release\kui_c_example_window_demo.exe 0Window, document and event loop
The source initializes the platform, creates a window and loads HTML. A timer updates #ticks during the event loop. The returned handles own references and must be released.
CHECK(kui_platform_init());
/* Zero first: every field treats 0 as "library default", so only what
* matters needs setting. */
memset(&props, 0, sizeof props);
props.title = "KUI C ABI - window demo";
props.width = 720;
props.height = 460;
props.centered = 1;
CHECK(kui_window_create(&props, &win));
/* The window owns its document; this hands back a counted reference. */
CHECK(kui_window_get_document(win, &doc));
CHECK(kui_document_load_html(doc, kHtml, 0));
/* Created windows are already visible, but showing again is harmless and
* makes the intent explicit. */
CHECK(kui_window_show(win));
Make one visible change
Change Hello from C in kHtml, rebuild the target and run the new EXE under build-c-examples. The heading should change while ticks keep updating.
" <h1 id='title'>Hello from C</h1>"If it does not run
If CMake fails, check cmake/KuiCConfig.cmake in the extracted SDK. If the EXE fails, check its adjacent runtime DLLs. If the window vanishes, pass 0.
Something unclear?
Report an issue on this page →