Because Everything searches instantly as you type, I often refine complex queries iteratively without pressing Enter. When I press Ctrl+Z repeatedly in the search box to step back through my edits, it only toggles back and forth between the last two states (standard Win32
"Edit"EM_UNDO(Using
search_history_add_delayWhile reading the earlier threads on search edit multiple undo (t=10577) and syntax highlighting (t=16625), I noticed your comment regarding why switching from the stock Windows edit control to RichEdit was put off:
Before writing a full custom edit control from scratch, I wanted to share a small Win32 detail that might save you from having to manually strip out formatting features:void wrote: The stock Windows edit control is rather limited. ...
I need to explore what is possible with a RichEdit control. This is also on my TODO list.
I don't want users to be able to format text in the search box so it would have to be trimmed down a lot.
EM_SETTEXTMODETM_PLAINTEXT | TM_MULTILEVELUNDOMSFTEDIT_CLASSMsftedit.dllHow it works:
By default,
MSFTEDIT_CLASSL"RichEdit50W"TM_RICHTEXTEM_SETTEXTMODECode: Select all
#include <richedit.h>
// 1. Load system Msftedit.dll and create MSFTEDIT_CLASS (L"RichEdit50W") instead of L"Edit"
LoadLibraryW(L"Msftedit.dll");
HWND hwndSearchEdit = CreateWindowExW(
0, MSFTEDIT_CLASS, L"",
WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL,
x, y, w, h, hwndParent, (HMENU)id, hInstance, NULL
);
// 2. Immediately after creation (while empty), lock into Plain-Text + Multi-Level Undo mode
SendMessageW(
hwndSearchEdit,
EM_SETTEXTMODE,
TM_PLAINTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE,
0
);
// 3. Enable EN_CHANGE / EN_UPDATE notifications to the parent window (disabled by default in RichEdit)
SendMessageW(hwndSearchEdit, EM_SETEVENTMASK, 0, ENM_CHANGE | ENM_UPDATE);
- No RTF / formatting to strip (): Pasting formatted text from a browser or Word via Ctrl+V is automatically coerced to plain Unicode text (
TM_PLAINTEXT). Formatting shortcuts (Ctrl+B, Ctrl+I, Ctrl+U), font/size changes, and OLE object drops are natively disabled by the control itself.CF_UNICODETEXT - Native Windows non-cycling multi-level Undo/Redo (): Instead of cycling between two states on Ctrl+Z, it provides standard Windows typing coalescing (grouping consecutive characters/deletions naturally), stops cleanly at the initial empty state without wrapping around, and supports Ctrl+Y (
TM_MULTILEVELUNDO). It also uses the control's own isolated undo stack (configurable viaEM_REDO) so it never pollutes the persistent Search History.EM_SETUNDOLIMIT - Drop-in message compatibility: Standard edit messages (,
WM_GETTEXT,WM_SETTEXT,EM_GETSEL,EM_SETSEL) work the same way as the stockEM_REPLACESELcontrol."Edit"
"Edit"1.
EM_SETEVENTMASKENM_CHANGEWM_COMMANDEN_CHANGE2. For dark mode colors,
MSFTEDIT_CLASSEM_SETBKGNDCOLOREM_SETCHARFORMATSCF_ALLWM_CTLCOLOREDITHope this is useful whenever you get around to looking at the search box control. Thanks again!