Either the dialog box closes and leaves and empty MDI child or I have problems with valid or disappearing menu.
I went back to basics and looked at sample testmdi4.prg
I found another reference in this forum about using GETKEYSTATE( VK_ESCAPE ) on the valid clause of activate dialog.
After some trial and error i have the following issue.
If I use a counter it seems the valid is called multiple times with 1 escape key press.
I wanted to try setting the valid to .t. if the escape key is pressed 2 times but remain if the escape key is pressed only 1 time.
I added the following valid clause with the counter checked for < 2 escape key pressed to return .f.. Unfortunately with 1 escape key press the dialog is closed code and the mdi child remains.
Code: Select all
local nCounter := 0 // Added to top of function child()
ACTIVATE DIALOG oDlg NOWAIT ; // It has to be NonModal --> NOWAIT clause
ON INIT oDlg:Move( 0, 0 ) ;
VALID ( if( GETKEYSTATE( VK_ESCAPE ), nCounter++, nil ), ;
tracelog( GETKEYSTATE( VK_ESCAPE ), nCounter ), ;
if( GETKEYSTATE( VK_ESCAPE ) .and. nCounter < 2, .f. , .t. ) )
The tracelog shows nCounter reached a total of 3. Somehow the valid clause is evaluated twice during the 1st escape key press.
Code: Select all
local nCounter := 0 // Added to top of function child()
ACTIVATE DIALOG oDlg NOWAIT ; // It has to be NonModal --> NOWAIT clause
ON INIT oDlg:Move( 0, 0 ) ;
VALID ( if( GETKEYSTATE( VK_ESCAPE ), nCounter++, nil ), ;
tracelog( GETKEYSTATE( VK_ESCAPE ), nCounter ), ;
if( GETKEYSTATE( VK_ESCAPE ) .and. nCounter < 3, .f. , .t. ) ) // Changed to check for 3 times