## Minimal program
```cpp
#include "ZufyUI.h"
#include "ZufyUIWidgets.h"
using namespace ZufyUI;
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) { // Windows subsystem (/SUBSYSTEM:WINDOWS)
Application app = Application::Instance();
auto win = app.CreateWindow(900, 600, L"Hello ZufyUI");
auto root = win->GetRootColumnBox(); // default root: ColumnBox, margin(20), spacing 10
auto btn = std::make_shared<Button>(L"Click me");
btn->Connect(btn->Clicked, [] { /* ... */ });
root->AddChild(btn);
win->Show(); // Create does NOT auto-Show (since v1.8.0)
return app.Run();
}
```
###block_red_start
**Pitfall**
- GUI apps use `wWinMain` + `/SUBSYSTEM:WINDOWS`. If you insist on `int main()`, set `/SUBSYSTEM:CONSOLE`, or add `#pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")` — otherwise the linker won't find an entry point.
###block_red_end
## Event loop & threading
- `Application::Run()` runs the single message loop; **all windows/controls must be created and touched on the same UI thread**.
- To touch UI from a worker: use a signal's `ConnectionThread::UIThread`, or `detail::PostToUIThread`.
## Structure (outer → inner)
`Application` (process) → `Window` (top-level, optionally owned/modal) → root `Layout` (default `ColumnBox`) → containers (`Card`/`PageHost`/`TabView`/`ScrollViewer`/data views/…) → controls.
Overlays (menus/dropdowns/tooltips/system dialogs) use separate windows or a global overlay — not the root tree.
## Suggested reading path
1. This chapter + "Conventions" (DIP / shared_ptr / signals / defaults).
2. UI: "Layout" + "Element base" + "Basic controls".
3. Data UI: "Data views".
4. Charts: "Charts".
5. Window extras (title bar/tray/dialogs/accessibility/debug): the matching chapter.Quick start
Minimal program, structure, reading path
Minimal program
cpp
#include "ZufyUI.h"
#include "ZufyUIWidgets.h"
using namespace ZufyUI;
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) { // Windows subsystem (/SUBSYSTEM:WINDOWS)
Application app = Application::Instance();
auto win = app.CreateWindow(900, 600, L"Hello ZufyUI");
auto root = win->GetRootColumnBox(); // default root: ColumnBox, margin(20), spacing 10
auto btn = std::make_shared<Button>(L"Click me");
btn->Connect(btn->Clicked, [] { /* ... */ });
root->AddChild(btn);
win->Show(); // Create does NOT auto-Show (since v1.8.0)
return app.Run();
}
Pitfall
- GUI apps use
wWinMain+/SUBSYSTEM:WINDOWS. If you insist onint main(), set/SUBSYSTEM:CONSOLE, or add#pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")— otherwise the linker won't find an entry point.
Event loop & threading
Application::Run()runs the single message loop; all windows/controls must be created and touched on the same UI thread.- To touch UI from a worker: use a signal's
ConnectionThread::UIThread, ordetail::PostToUIThread.
Structure (outer → inner)
Application (process) → Window (top-level, optionally owned/modal) → root Layout (default ColumnBox) → containers (Card/PageHost/TabView/ScrollViewer/data views/…) → controls.
Overlays (menus/dropdowns/tooltips/system dialogs) use separate windows or a global overlay — not the root tree.
Suggested reading path
- This chapter + "Conventions" (DIP / shared_ptr / signals / defaults).
- UI: "Layout" + "Element base" + "Basic controls".
- Data UI: "Data views".
- Charts: "Charts".
- Window extras (title bar/tray/dialogs/accessibility/debug): the matching chapter.