Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

activate to toolbar save button using getfldstate() 1

Status
Not open for further replies.

kosta

Programmer
Feb 9, 2001
186
0
0
CA
Hi All,
i am using my own toolbar and still working with Edit/Save/Revert method ( like classic wizbtn.vcx ) . By this way user pressing the edit button then toolbar turning to Save/Revert position . I want to do this when user changed some field on the form ; it should automatically no need to wait press edit button for save . How can i do this with getfldstate() ? and how can i tell to toolbar when the some fields changed

TIA

Soykan OEZCELIK
 

You can check the getFldState() from the valid of the textboxes.

nState=GETFLDSTATE(this.controlsource)
or
nState=GETFLDSTATE(juststem(this.controlsource)) && If you use table name also

If nState = 2 && Field has changed value
oToolbar. &&&
endif






Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
OK but by this way i should use textbox,editbox,grid class containig these codes for this control . i am right ?

Soykan OEZCELIK
 
Kosta

If you need to check every control of the form, yes it should go in every valid of each control of the form, or create a method of the form, and send a paramter to the method (the controlsource) to make it more generic.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
for eg.

a textbox class code with interactive change event
thisform.changed=.t. (and also editbox vs what is the need)

a baseform , it'll contain changed property valued .f. a code to its assign method

if thisform.changed=.t.
otoolbar.cmdsave.enabled=.t.
endif

for grids will use tha same custom txtbox class for this action

is it true ?

Soykan OEZCELIK
 
Yes that is correct.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Instead of checking if something has changed in the controls, I use a timer that checks every few miliseconds if something has changed useing the following method:

GETNEXTMODIFIED()

I use a method in my business object that is fired and checks if the record has changed.
If this method IsChanged() returns True, something has changed and the buttons 'Save' on my form as well as my toolbar are enabled and others are disabled accordingly.
Of course to make it robust, the timer is stopped as soon as something has changed.

HTH,






Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Weedz would you like send me sample about your method ?

soykanozcelik@web.de

TIA & Kind Regards

Soykan OEZCELIK
 
Thanks Weedz,
i have download it its a great work congrulations,
i need only part of ischanged() and methods,properties .
would you like to explain me step by step what should i do . i think i need a form with a ischanged method and timer for check the changes... i didn't have any good idea where from should i start. if you help me it would very appreciated.

TIA

Soykan OEZCELIK
 
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....[bigglasses]

let me know if it works.


Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top