Ok., no problem, I am in the bosses time anyhow ;-)
(Note that this is a simple solution, as you could see in my little app I used a somewhat complexer approach using sublclassing etc.)
Step 1: Create a form with input controls and action buttons
Step 2: Put a timer on that form and set the interval to 100
Step 3: Create a method in that form called IsChanged()
If you only use one table in your form, it would be prudent to make a property f.i cAlias and use this property in all your references to this particular table. But if you use more than one table you might opt to parse the table name as a parameter.
In the example I have chosen the first option.
Code:
*- Returns true if records have changed in the given table
LOCAL llRetVal
llRetVal = !(GETNEXTMODIFIED(0 , THIS.cAlias) == 0)
RETURN llRetVal
[\code]
Step 4: Make a method that enables and disables buttons whose enabled property depends on the state of your record (changed or not).
F.i. EnableButtons()
[code]
LPARAMETERS tlEnable
WITH THIS
.cmdSave.enabled = tlEnable
.cmdNew.Enabled = Not tlEnable
...etc.
ENDWITH
[\code]
Note that I haven't used the ischanged() method in the EnableButtons() method itself and instead used a parameter, this allows you to enable/disable buttons in certain other situations...
In the timer event of your timer, code the folowing:
[code]
LOCAL llRetVal
llRetVal = DODEFAULT()
IF llRetVal
THIS.PARENT.EnableButtons(THIS.PARENT.IsChanged())
ENDIF
RETURN llRetVal
To make it more robust, you could disable the timer as soon as something has changed, and as soon as there is a situation where nothing has changed you restart the timer again.
As I stated this is just a simple example that I actually just wrote by heart, so I haven't tested it....
let me know if it works.
Weedz (Edward W.F. Veld)
My private project:
Download the CrownBase source code !!