Hi,
How can I detect that the contents of an @EDIT box have changed - so I can prompt a user to save / discard the change?
CONTROL f3,@EDIT,"",305,140,60,25,0x50800000|@TABSTOP,4107
So f3 is the window, and the edit is 4107
The edit box can be either blank or contain something like "0900"
If the users changes "0900" to "1000" is there a simple way to detect this?
Thanks,
Andy.
Of course...
You must have few more variables like
tempStatus = "00"
if enyone put something different like
newStatus="09"
so
If tS <> nS
count++
Endif
something like this... ;)
Two ways come to mind:
The first doesn't worry about the contents at all, just whether or not it has changed.
If the initial value is 0900 and the User types 1000 and then types 0900 that will still fire the prompt.
int changeflag=0
int fp=0
SUB wndproc(),int
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
closewindow f3
case @IDCONTROL
select @CONTROLID
case 4107
select @notifycode
case @ENCHANGE 'fired every time control changes
if fp<>0
changeflag =1
else
fp=1
endif
case @ENKILLFOCUS
if changeflag = 1
changeflag=0
fp=0
if messagebox( f3,"4107 has changed\nSave changes?","Entry changed",@MB_YESNO )=@IDYES
'save change
endif
endif
endselect
endselect
ENDSELECT
RETURN 0
ENDSUB
The 2nd way only prompts when the ending value is actually different from the starting value.
The ltrim$/rtrim$/lcase$ commands are needed because of all the ways a User can type the input.
int changeflag=0
int fp=0
SUB wndproc(),int
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
closewindow f3
case @IDCONTROL
select @CONTROLID
case 4107
select @notifycode
case @ENCHANGE 'fired every time control changes
if fp<>0
changeflag =1
else
fp=1
endif
case @ENKILLFOCUS
if changeflag = 1
changeflag=0
fp=0
if messagebox( f3,"4107 has changed\nSave changes?","Entry changed",@MB_YESNO )=@IDYES
'save change
endif
endif
endselect
endselect
ENDSELECT
RETURN 0
ENDSUB
Between the two you should be able to make it do what you want.
Thanks Aurel and Larry,
That has given me plenty to try!
should keep me quiet at least for one day :)
Once again,
Thanks,
Andy.
LarryMc,
For readability, could you limit your indents to 3 in
your code. Above, you started out okay, then it all
went to hell.
Thanks,
Bill
Quote from: Bill-Bo on September 17, 2013, 10:13:29 AM
LarryMc,
For readability, could you limit your indents to 3 in
your code. Above, you started out okay, then it all
went to hell.
Thanks,
Bill
My indents are set to 3 and it looks correct in the IDe but when I copy and paste it to the forums it looks like that.
And when I preview it before I post it it doesn't show any indents.
I don't know what the deal is.
strange, if I don't put it in a code /code block it formats okay
LarryMc,
Yes, it is very strange. It looks okay out of the code box.
Maybe the server has had a glitch.
I hate to ask, again. I lost your reply to me as to how to
select to the code in a codebox. Could you please re-send?
Thanks,
Bill
Bill,
Left click at the start of the code (you won't see a cursor) - then Shift+Left click at the end ..
A Ctrl+C, and you're ready to do a Ctrl+V wherever you want to put it .. :)
Graham
Quote from: GWS on September 17, 2013, 01:08:32 PM
Bill,
Left click at the start of the code (you won't see a cursor) - then Shift+Left click at the end ..
A Ctrl+C, and you're ready to do a Ctrl+V wherever you want to put it .. :)
Graham
And Bill, if you do what Graham says inside one of those Code blocks that has the huge tabs and then paste it in an iwb file it will look like it is suppose to.