Hand-built Windows sticky notes starter in C++20 + Win32 + Direct2D + DirectWrite.
The project is intentionally built without RichEdit. The text core is owned by the app:
- Plain text only
- Bold is the only inline style
- Floating launcher with recent notes
- Minimal main window with a custom rendered editor surface
- IME composition preview through IMM
- Autosave to local files
The UI follows a restrained Raster-NOTON inspired direction:
- neutral paper-like background
- black grid lines and thin borders
- uppercase utility labels
- dense but quiet information hierarchy
- almost no ornamental chrome
RichEdit is powerful, but it is also heavier than this app needs. This starter keeps the critical path in local code:
- custom gap-buffer text storage
- custom bold-range model
- DirectWrite layout generated on demand
- Win32 input, selection, clipboard and IME handling
- note persistence in a tiny custom file format
That keeps the editing model understandable, hackable, and performance-focused.
src/text_document.*
- custom gap buffer for low-overhead insertion near the caret
- selection state, caret movement, delete/insert logic
- non-overlapping bold ranges with merge/split logic
src/note_store.*
- stores notes in
%LOCALAPPDATA%\\RasterNoteNative\\notes - one
.rnotefile per note - UTF-8 text body plus serialized bold spans
src/note_app.*
- launcher window and main window
- Direct2D render targets
- DirectWrite text layout cache
- hit testing, selection painting, caret painting
- clipboard, IME preview, autosave timer
This starter is biased toward smoothness first:
- no heavyweight edit control
- text layout is rebuilt lazily, only when content or width changes
- only one lightweight brush per render target
- note files are tiny and saved independently
- selection and caret are rendered directly from cached layout hit-testing
For the next optimization pass, the most valuable upgrades are:
- add an undo/redo command stack
- move note saving to a background worker
- switch from
ID2D1HwndRenderTargetto a DXGI flip-model swap chain - add virtualization if the recent-note list grows large
- add richer IME caret feedback inside the composition range
Recommended toolchain:
- Visual Studio 2022 Build Tools, or full Visual Studio 2022
- Windows 10/11 SDK
- CMake 3.24+
Configure:
cmake -S . -B build -G "Visual Studio 17 2022"Build:
cmake --build build --config ReleaseCtrl+N: new noteCtrl+S: save nowCtrl+B: toggle boldCtrl+A: select allCtrl+C / Ctrl+X / Ctrl+V: clipboardEsc: hide the main window or close the expanded launcher
Each note is stored as a simple text file:
RASTERNOTE/1
modified=1711111111
bold=0:5,18:4
---
actual text body here
This is easy to inspect, migrate, sync, and replace later.