Hello,
I noticed that LastKey() has a strange behaviour.
This is my code :
-------------------------------------
PRIVATE Niv := 1
DEFINE DIALOG DiaDlg NAME "DIALOG"
REDEFINE oGET1 VAR FIELD1 ID 101 OF DiaDlg PICTURE "XXX"
...
REDEFINE oGET9 VAR FIELD9 ID 109 OF DiaDlg PICTURE "XXX"
REDEFINE BUTTON ID 200 OF DiaDlg ACTION(Niv:=9,DiaDlg:End())
REDEFINE BUTTON ID 201 OF DiaDlg ACTION(Niv:=0,DiaDlg:End())
ACTIVATE DIALOG DiaDlg CENTERED
IF LastKey() = VK_ESCAPE ; Niv := 0 ; ENDIF
-------------------------------------
What do I want to do ?
Button 200 is a button "Save"
Button 201 is a button "Quit"
If niv = 9, the data will be saved. If niv = 0, the program will check whether there is a difference between the data on the screen and the data on disk. If all the data are the same, the procedure will be ended, otherwise the user will be asked if he is sure that the data will not be saved.
I want that the user also can use the Escape-key which has to behave like the button "Quit".
So, If the user clicks "Quit", niv = 0 but also if the Escape-key is pressed, niv = 0.
But what is happening ?
Once I have pressed the Escape-key, lastkey() keeps positioned on the Escape-key. If button "Save" is clicked the next time, the program will always act as if the Escape-key has been pressed.
I added the test : MsgInfo(LastKey()). It always returns (27 = Escape), even it the lastkey wasn't the Escape-key at all.
Can anyone tell me what's wrong ?
Thank you very much in advance for any help.
Michel
Strange behaviour of LastKey()
Strange behaviour of LastKey()
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Strange behaviour of LastKey()
Michel
Try it this way
ACTIVATE DIALOG ODLG CENTERED VALID ( ESC_DIALOG() )
FUNCTION ESC_DIALOG
IF GETASYNCKEY( 27 )
IF msgyesno("Voulez-vous tout annuler ?","Veuillez confirmer")
return .T.
ELSE
return .F.
ENDIF
ENDIF
return .T.
Hth
Richard
Try it this way
ACTIVATE DIALOG ODLG CENTERED VALID ( ESC_DIALOG() )
FUNCTION ESC_DIALOG
IF GETASYNCKEY( 27 )
IF msgyesno("Voulez-vous tout annuler ?","Veuillez confirmer")
return .T.
ELSE
return .F.
ENDIF
ENDIF
return .T.
Hth
Richard
Richard,
Thank you very much for your help.
I think you solved my problem.
Michel
Thank you very much for your help.
I think you solved my problem.
Michel
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7