[SOLVED] Knowing When Text Changed

Just starting out? Need help? Post your questions and find answers here.
Randy Walker
Addict
Addict
Posts: 1059
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

[SOLVED] Knowing When Text Changed

Post by Randy Walker »

How does NotePad or any other app know if text was changed? Even as little as one character, it always seems to know.
Last edited by Randy Walker on Sun Aug 03, 2025 10:12 pm, edited 1 time in total.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
infratec
Always Here
Always Here
Posts: 7613
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Knowing When Text Changed

Post by infratec »

Randy Walker
Addict
Addict
Posts: 1059
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Knowing When Text Changed

Post by Randy Walker »

Wow! Thanks infratec. So much more complex than I imagined.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: [SOLVED] Knowing When Text Changed

Post by BarryG »

For your own apps, you can use #PB_EventType_Change for some gadgets to know when they've changed, or use GetGadgetText() and compare it with a previous GetGadgetText() to see if the text differs.

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).
Axolotl
Addict
Addict
Posts: 832
Joined: Wed Dec 31, 2008 3:36 pm

Re: [SOLVED] Knowing When Text Changed

Post by Axolotl »

Even if the post is marked as solved.
For completeness, there are also the API functions under Windows that can upgrade an EditorGadget() ....
A small extract to answer the above question:

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
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Randy Walker
Addict
Addict
Posts: 1059
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: [SOLVED] Knowing When Text Changed

Post by Randy Walker »

Thanks Axolotl... And looks so much simpler too.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1059
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: [SOLVED] Knowing When Text Changed

Post by Randy Walker »

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...
Hadn't considered it might be detected by EventType() so that's a really great tip!!
or use GetGadgetText() and compare it with a previous GetGadgetText() to see if the text differs.
Well yeah that's the obvious way, but bothersome.
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).
Good info, but way outside of my interest. just wanted to know about changes to editor and string gadgets.
THANKS BarryG!!!
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: [SOLVED] Knowing When Text Changed

Post by BarryG »

Was detecting the change for your own app, or for third-party apps? Because you only mentioned Notepad (third-party).
Randy Walker
Addict
Addict
Posts: 1059
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: [SOLVED] Knowing When Text Changed

Post by Randy Walker »

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).
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.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Post Reply