Mr Samir
The code you posted in your first post itself is working well for me, in the sense that the picture is changed and the new picture is functioning successfully.
This is the simple program I tested.
- Code: Select all Expand view
function GetPic()
local n1 := 0, n2 := 1.234
local aGet[ 2 ]
local oDlg
DEFINE DIALOG oDlg SIZE 200,200 PIXEL
@ 10,10 GET aGet[ 1 ] VAR n1 PICTURE "999,999.99" SIZE 60,12 PIXEL OF oDlg RIGHT ;
VALID ChangePic( oDlg, aGet )
@ 30,10 GET aGet[ 2 ] var n2 PICTURE "999,999.99" SIZE 60,12 PIXEL OF oDlg RIGHT ;
VALID ( oDlg:Update(), .t. )
@ 50,10 SAY n2 PICTURE "999,999.9999" SIZE 60,10 PIXEL OF oDlg UPDATE
@ 70,10 BUTTON "OK" SIZE 30,14 PIXEL OF oDlg ACTION MsgInfo( Transform( n2, "999,999.9999" ) )
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//
static function ChangePic( oDlg, aGet )
WITH OBJECT aGet[ 2 ]
if !( ".999" $ :cPicture )
:cPicture := ;
:oGet:picture := "999,999.999"
:Refresh()
endif
END
return .t.
The logic is exactly the same as yours in the first posting.
Initially the picture of the second get is set to 2 dec. places.
The valid clause of the first get changes the picture of second get to 3 dec.places.
After the valid clause changes the picture of second get, I observed that the second get is behaving exactly the same way as if the changed picture was set originally.
This is the screen shot initially. First get has input focus.
Entered some value in the first get and the focus shifted to second get. We can now see that the picture is changed successfully and see the value with 3 decimal places.
You said:
With this the picture is changed, but only if I press "." ( dot ) before the first decimal be filled I can add the third decimal.
.....
.....
123456789 = Fail => 123,456.780
What I observed is different.
I now entered 123456789.
This is the result:
In this case result of entering
123456789 = success = 123,456.789.
I tested with both Harbour and xHarbour and latest FWH.
You have also observed:
1234567.89 = Fail => 123,456.790
12345678.9 = Fail => 123,456.790
Actually pressing decimal after the cursor moves post decimal place is not common. After digits 123456 are entered the Get automatically moves the cursor to the right of the decimal place. After entering one digit and then press "." the behaviour is different in Harbour and xHarbour.
If we are not agreeable with the behaviour of what happens when we press '.' after crossing the decimal point, that has nothing to do with dynamically changing the picture. What I can definitely say is that it is the same behaviour whether the 3 decimal picture was originally specified or dynamically changed during program execution.
In my view, your original code was adequate to successfully change the picture. There is no need to keep on trying different alternatives. If you find that it does not, then may be it is an issue with the versions you are using.