[SOLVED] Knowing When Text Changed
Posted: Sun Aug 03, 2025 9:11 pm
How does NotePad or any other app know if text was changed? Even as little as one character, it always seems to know.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
; query the EditorGadget for modified text since last reset
;
Macro EditorGadget_IsModified(Gadget)
SendMessage_(GadgetID(Gadget), #EM_GETMODIFY, #Null, #Null)
EndMacro
; reset EditorGadget modify flag
;
Macro EditorGadget_ResetModified(Gadget)
SendMessage_(GadgetID(Gadget), #EM_SETMODIFY, #False, #Null)
EndMacro
Hadn't considered it might be detected by EventType() so that's a really great tip!!BarryG wrote: Mon Aug 04, 2025 12:15 am For your own apps, you can use #PB_EventType_Change for some gadgets to know when they've changed...
Well yeah that's the obvious way, but bothersome.or use GetGadgetText() and compare it with a previous GetGadgetText() to see if the text differs.
Good info, but way outside of my interest. just wanted to know about changes to editor and string gadgets.To detect changes in third-party apps like Notepad, you'd need to parse its window to get all its "gadgets" and then check the one with the "Edit" class (similar to what I said about GetGadgetText() above).
Was thinking of my own app and using NotePad as an example of an app that exhibits that feature. Sorry for confusion and not being more explicit.BarryG wrote: Mon Aug 04, 2025 10:56 pm Was detecting the change for your own app, or for third-party apps? Because you only mentioned Notepad (third-party).