( Status Bar, Check Box )
We are continuing with Viva_HMG.hbp, Main.prg and Main.fmg.
While using a table and while navigating between its records, we need some extra info to show to user: Name of table, current record and record count in the table. So user always feels comfortable by knowing where is he / she; which table, which record?
The status bar control is convenient for this purpose and though this is a quite simple control, IDE has a builder for it: Status bar builder.
When you choose this builder ( after open the .fmg file by IDE of course ), a dialog box will open:
By using this dialog box we can define a status bar. We can prefer define status bar manually too:
DEFINE STATUSBAR FONT "Tahoma" SIZE 9 STATUSITEM "" WIDTH 300 STATUSITEM "" WIDTH 40 DATE WIDTH 90 CLOCK WIDTH 90 END STATUSBAR
After define status bar, we need assign values to its items. We don’t need assign values to DATE and CLOCK items, because these items will be updated by system (HMG) automatically.
First a little procedure :
PROCEDURE InitEdit()
EditReco.StatusBar.Item( 1 ) := cTableFNam
ReadData()
RETURN // InitEdit()
Change ON INIT event of EditReco form from ReadData() to InitEdit(.
And add this line at end of ReadData() procedure.
EditReco.StatusBar.Item( 2 ) := LTRIM( STR( RECN() ) ) + "\" + ; LTRIM( STR( LASTREC() ) )
Let’s look at the result :
Whenever active record change, Item( 2 ) of Status Bar will be updated ( 5/25 ) in above picture.
In this step, user must use “Save” button every time current record edited. Whereas “Read” process is different; whenever current record changed, values of text boxes automatically updated. What about automatic save? May be, we can do this; but user may don’t want such automation. Asking a question like “Do you want save?” every change doesn’t a good way.
The better way may be: put a control to form such “Auto save” with On / Off option.
Yes, fortunately we have such control: Check Box.
We can replace a Check Box control to EditReco form with chbAutoSave name and Auto Save caption:
Now, how we will implement Auto Save process?.
By adding a little IF clause to ACTION events of navigation buttons:
Top : (IF(EditReco. chbAutoSave.Value , SaveData(), ), DBGOTOP(), ReadData() )
Next : (IF(EditReco. chbAutoSave.Value , SaveData(), ), DBSKIP(), ReadData() )
Previous : ( IF(EditReco. chbAutoSave.Value , SaveData(), ), DBSKIP( -1 ), ReadData() )
Last : (IF(EditReco. chbAutoSave.Value , SaveData(), ), DBGOBOTTOM(), ReadData() )
To be continued …