Build a real native Notepad.
Start from the maintained template, then add one safe vertical slice at a time: document state, Unicode files, commands, editor workflows, persistence, accessibility, tests, and packaging.
templates/basic-appProve the untouched template first
Copy-Item -Recurse .\templates\basic-app ..\mwfl-notepad-tutorial
Set-Location ..\mwfl-notepad-tutorial
cmake -S . -B build -G "Visual Studio 18 2026" -A x64 `
-DMWFL_SOURCE_DIR=D:/GitHub/mwfl
cmake --build build --config Debug
Visual Studio 2022 is equally supported; use generator Visual Studio 17 2022 and a separate build directory.
Compose the document surface
SetLayout(mwfl::Column()
.Add(toolbar_, mwfl::Auto())
.Add(editor_, mwfl::Stretch())
.Add(status_, mwfl::Auto()));
All wrappers are window members. The edit control stretches; native toolbar and status-bar measurements are converted through the Per-Monitor-V2 DIP layout.
Make destructive actions safe
DocumentState decides whether a transition may proceed. The application asks Save, Discard, or Cancel before New, Open, close-window, and Exit. It marks a path or saved state only after I/O succeeds.
ReadTextFile validates UTF-8/UTF-16. WriteTextFileAtomic flushes a sibling temporary file, checks the original FileStamp, and atomically replaces the destination.
Share commands, do not copy callbacks
commands_.Add(mwfl::Command(kSave, L"&Save", [this] {
static_cast<void>(SaveDocument(false));
}).SetShortcut({FVIRTKEY | FCONTROL, 'S'}));
The same command supplies menu, toolbar, accelerator, checked/visible state, and callback. The focused Agent recipe adds the persisted Always on Top command without inventing an API.
Verify the real executable
cmake --preset vs2026-x64
cmake --build --preset x64-debug --target mwfl_notepad
ctest --preset x64-debug -R "mwfl.notepad_gui" --output-on-failure
The hidden-window workflow covers launch, edit notification, atomic save, cancel, discard, reopen, command state, MSAA names, theme and DPI refresh, 50 repeated document cycles, resource growth, and close.
Install or package it
cmake --build --preset x64-release
cmake --install build\presets\vs2026-x64 --config Release --prefix build\install
& .\build\install\bin\mwfl_notepad.exe
The CPack ZIP includes the executable, library, public headers, CMake package files, licenses, and documentation.